The density does not hold even in the compact connected case: if $X=Y=Z=\mathbb S^1\simeq\mathbb R/\mathbb Z$ and $f:\theta\mapsto2\theta$, then any composition $f\circ g$ has even degree, for instance it cannot be too close to the identity map.

I believe however that the following holds.

**Proposition.**
If $X$ is compact, the composition operator $f_*$ is open in the Whitney topology.

In particular, it would imply that its range $R$ is open, so that for any pair of homotopic maps $\phi\simeq\psi:X\to Z$, $\phi\in R$ if and only if $\psi\in R$. In other words, and as the above example suggests, obstructions to being in $R$ are topological.

### Sketch of proof

I assume (without loss of generality, up to working component by component) that $X$, $Y$ and $Z$ are connected. I make the additional assumption that $Y$ is compact also, although I don't think it is needed; see below.

*Proof.* Let $TY\to Y$ (resp. $TZ\to Z$) be the the tangent bundle of $Y$ (resp. $Z$), and $\ker Tf\to Y$ be the kernel of the bundle map $Tf:TY\to TZ$. Note that $\ker Tf$ is indeed a vector bundle since $f$ is a submersion, and it is in fact a subbundle of $TY$. As such, it admits a complement, i.e. a subbundle $F\to Y$ of $TY$ such that $F_y\oplus \ker T_yf=T_yY$ at all points $y$ of $Y$.¹ In particular, $T_yf$ restricted to $F_y$ is an isomorphism for all $y\in Y$.

Identify a neighbourhood $V$ of the zero section in $TY$ to a neighbourhood $V'$ of the diagonal in $Y\times Y$, through a diffeomorphism $\mu:V\to V'$.²

**Lemma.**
The function $\alpha:(y,y')\in\mu(F\cap V)\mapsto(y,f(y'))\in Y\times Z$ is a (smooth) diffeomorphism on a neighbourhood $U$ of the diagonal.

Assume for now that the lemma is true, and let's see how the proposition follows. Let $f\circ g$ be an element of the range $R$, and $\phi_n:X\to Z$ a sequence of maps converging to $f\circ g$ in the Whitney topology. We need to show that $\phi_n=f\circ g_n$ for all $n$ large enough, for a sequence $g_n$ that converges to $g$. The existence of $g_n$ is a consequence of the lemma: at some point, $\phi_n$ is sufficiently close to $f\circ g$ in the uniform topology so that $(g(x),\phi_n(x))$ belongs to $\alpha(U)$. Then, setting $(g,g_n) := \alpha^{-1}\circ(g,\phi)$, we have $\phi_n=f\circ g_n$ as announced. Now it suffices to show that $g_n$ converges to $g$ in the Whitney topology, i.e. that all their derivatives converge uniformly to that of $g$. But it is clear from the definition of $g_n$.

*Proof of the lemma.* The differential of $\alpha$ can be decomposed according to the structure of $Y\times Y$ and $Y\times Z$; along the diagonal, we have
$$ T\alpha=\begin{pmatrix}\mathrm{id}&*\\0& Tf_{|F}\end{pmatrix}. $$
According to the inverse function theorem, $\alpha$ is a local diffeomorphism on a neighbourhood of the diagonal. Then it is enough to show that it is injective on a smaller neighbourhood.

Let $(y_n,y'_n)$ and $(\tilde y_n,\tilde y'_n)$ be sequences with values in $\mu(F\cap V)$ such that they both approach the diagonal³ and $\alpha(y_n,y'_n)=\alpha(\tilde y_n,\tilde y'_n)$. It suffices to show that they coincide for an infinite number of $n$. In fact, $y_n=\tilde y_n$ by definition of $\alpha$. Up to considering a subsequence, we can assume that $y_n$ converges, say to $y$. Now if $W$ is a neighbourhood of $(y,y)$ in $\mu(F\cap V)$ over which $\alpha$ is a diffeomorphism, $(y_n,y'_n)$ and $(\tilde y_n,\tilde y'_n)$ must belong to that neighbourhood for $n$ large enough, so that they are in fact equal. This concludes the proof of the lemma.

### The non-compact case

We have used the fact that $Y$ is compact in the proof of the lemma. However, we need only assume that $\alpha$ is a diffeomorphism on a neighbourhood of the image of $(g,g)$, which is compact; the proof is then the same.

I don't know what happens in the case where $Y$ is compact but $X$ is not; I would guess it still holds, based on sheer intuition. If neither are, for $f$ the inclusion of an open arc in the circle, and $g$ the identity of said arc, $f_*$ is not open at $g$.

¹ For instance, fix a Riemannian metric on $Y$ and consider the orthonormal complement.

² For instance, $\mu$ could be the exponential map associated any Riemannian metric on $Y$.

³ In any reasonnable sense, say $d(y_n,y'_n)\to0$ for a Riemannian distance $d$.