Edit 1. I realized my proof has a mistake. Because I use the inverse function theorem on $g \circ f$, my answer only checks out if $g \circ f$ is required to be continuously differentiable.
Original answer. Here's a counterexample.
We say a function $f$ is locally injective at a point $x$ if there exists a small interval $(x - \delta, x + \delta)$ where $x$ is injective. Suppose we have a function $f$ that is not locally injective at a point $x$. Also, suppose we have a function $g$ where the composition $g \circ f$ is differentiable at $x$. Note that because $f$ is not locally injective at $x$, $g \circ f$ cannot be locally injective by $x$. So by the inverse function theorem, its derivative $(g \circ f)'$ must necessarily vanish at $x$. This leads us to the following question:
Question. Can we find a function that is everywhere continuous, but nowhere locally injective?
If we can find such a function $f$, then any composition $g \circ f$ must be have an identically zero derivative. This means $g \circ f$ must be constant, implying $g$ is constant (at least in the range of $f$)!
We can achieve this with a function $f$ that is everywhere continuous, but nowhere differentiable. There are many such functions, the most famous being the “pathological” Weierstrass function. To prove $f$ is nowhere locally injective, suppose toward a contradiction that it is locally injective at a point $x$. Then there is in a small interval $I$ about $x$ where $f$ is injective and continuous, and hence monotone. By Lebesgue's monotone function theorem referenced in this post, $f$ must be differentiable almost everywhere in $I$. This is a contradiction because $f$ is nowhere differentiable.
Edit 2. Instead of examining local injectivity, we can maybe examine a slightly stronger condition. Let's say a function $f$ has a corner (not an actual term) at a point $x$ if for all $\delta > 0$, there exists $x_1, x_2 \in (x - \delta, x + \delta)$ such that $x_1 < x < x_2$ and $f(x_1) = f(x_2)$. The key here is that a “corner” requires the points breaking injectivity to lie on both sides of $x$.
We can show that if $f$ has a corner at $x$ and $g \circ f$ is differentiable at $x$, then $(g \circ f)'$ must vanish at $x$. For all $\delta > 0$, let $x_{1, \delta} < x < x_{2, \delta}$ be as in the definition of a corner. Taking the left-side points, we get
$$
\tag{1}
(g \circ f)'(x) = \lim_{\delta \to 0^+}
\frac{(g \circ f)(x_{1, \delta}) - (g \circ f)(x)}
{x_{1, \delta} - x},
$$
and taking the right-side points, we get
$$
\tag{2}
(g \circ f)'(x) =
\lim_{\delta \to 0^+} \frac{(g \circ f)(x_{2, \delta}) - (g \circ f)(x)}
{x_{2, \delta} - x}.
$$
Note that the numerators of $(1)$ and $(2)$ are equal because $(g \circ f)(x_{1, \delta}) = (g \circ f)(x_{2, \delta})$. However, the denominators $x_{1, \delta} - x$ and $x_{2, \delta} - x$ have opposite signs, so we must have $(g \circ f)'(x) = 0$. Therefore, we can instead ask the question:
Question. Can we find a function that is everywhere continuous, but has a corner at every point in $\mathbb{R}$?
Because the Weierstrass function behaves like a fractal, this seems like it would be true (but maybe it only has corners densely packed in $\mathbb{R}$, in which continuous differentiability comes back to bite us). I'm not sure how to prove this though.