Proof.
The implication $(2) \Rightarrow (1)$ is immediate from the definition. We now show that $(1) \Rightarrow (2)$. Assume that $U: \operatorname{\mathcal{D}}\rightarrow \operatorname{\mathcal{C}}$ is a cartesian fibration of categories. Then $U$ is also a locally cartesian fibration (Example 11.10.3.11). Let $f: X \rightarrow Y$ be a locally $U$-cartesian morphism in $\operatorname{\mathcal{D}}$. Since $U$ is a cartesian fibration, we can choose a $U$-cartesian morphism $f': X' \rightarrow Y$ satisfying $U(X') = U(X)$ and $U(f') = U(f)$. Using our assumption that $f$ is locally $U$-cartesian, we deduce that $f'$ factors uniquely as a composition $f \circ e$, where $e: X' \rightarrow X$ has the property that $U(e) = \operatorname{id}_{ U(X)}$. Since $f'$ is locally $U$-cartesian, the morphism $e$ is an isomorphism (Remark 11.10.3.6). Applying Remark ***, we deduce that $f = f' \circ e^{-1}$ is also $U$-cartesian.
The implication $(2) \Rightarrow (3)$ follows from Remark ***. We will complete the proof by showing that $(3) \Rightarrow (2)$. Assume that $U$ is a locally cartesian fibration of categories and that the collection of locally $U$-cartesian morphisms of $\operatorname{\mathcal{D}}$ is closed under composition. Let $g: X \rightarrow Y$ be a locally $U$-cartesian morphism in $\operatorname{\mathcal{D}}$; we wish to show that $g$ is $U$-cartesian. Fix an object $W \in \operatorname{\mathcal{D}}$ and a morphism $\overline{f}: U(W) \rightarrow U(X)$, so that postcomposition with $g$ induces a function
\[ \theta : \{ f \in \operatorname{Hom}_{\operatorname{\mathcal{D}}}(W,X): U(f) = \overline{f} \} \rightarrow \{ h \in \operatorname{Hom}_{\operatorname{\mathcal{D}}}(W,Y): U(h) = U(g) \circ \overline{f} \} . \]
We wish to show that $\theta $ is a bijection. To prove this, we invoke our assumption that $U$ is a locally cartesian fibration to choose a locally $U$-cartesian morphism $f': W' \rightarrow X$ in $\operatorname{\mathcal{D}}$ satisfying $U(W') = U(W)$ and $U(f') = \overline{f}$. We then have a commutative diagram
\[ \xymatrix@R =50pt@C=-50pt{ & \{ e \in \operatorname{Hom}_{\operatorname{\mathcal{D}}}(W,W'): U(e) = \operatorname{id}_{U(W)} \} \ar [dl]^{f' \circ } \ar [dr]_{g \circ f' \circ } & \\ \{ f \in \operatorname{Hom}_{\operatorname{\mathcal{D}}}(W,X): U(f) = \overline{f} \} \ar [rr]^-{\theta } & & \{ h \in \operatorname{Hom}_{\operatorname{\mathcal{D}}}(W,Y): U(h) = U(g) \circ \overline{f} \} . } \]
Since $f'$ and $g \circ f'$ are locally $U$-cartesian, the vertical maps in this diagram are bijections. It follows that $\theta $ is also a bijection, as desired.
$\square$