[Edited typo 01/16/2022]
Let $\pi:T^*M \to M$ be the canonical projection. Given a diffeomorphism of the base $f:M\to M$, the pullback mapping $f^*:T^*M \to T^*M$ is again a diffeomorphism, and one has commutativity $d\pi\circ d(f^*) = df \circ d\pi$, where $df$ is the usual differential and $d(f^*):TT^*M \to TT^*M$ is the differential of the pullback diffeomorphism $f^*$.
From the commutativity of the pullback diagram, we find that $(f^*)^* \theta=\theta$, where we recall that the $1$-form $\theta$ on $T^*M$ is defined as $\theta_{(p,\alpha)}(v)=\alpha_p(d\pi_{(p,\alpha)}(v))$, where $v \in T_{(p,\alpha)} T^*M$.
Suppose now we are given a diffeomorphism $F:T^*M \to T^*M$ of the cotangent bundle. If $F$ does not preserve the fibres of $\pi$, then there is no chance of $F$ being induced by a diffeomorphism of the base (this even if $F^*\theta=\theta$). Supposing that $F$ $does$ preserve fibres, then we obtain a diffeomorphism $f:M\to M$ of the base. Now our task is to show that if $F^* \theta=\theta$, then $F=f^*$. So let's say we're given a diffeomorphism $G:T^*M \to T^*M$ with $G^*\theta=\theta$ and which induces the identity map on the base $M$. Taking differentials gives us the handy relation $d\pi \circ dG =d\pi$. Of course, i'mI'm thinking of $G=F^{-1}\circ f^*$ and we want to find if $G$ is the identity mapping.
As $G$ induces the identity mapping on the base, the diffeomorphism $G$ induces at every point $p\in M$ a fibre-diffeomorphism $G_p:T^*_p M \to T^*_p M$. That is, $G$ acts like $(p,\alpha)\mapsto (p, G_p\alpha)$. We want to show that $G_p$ is the identity mapping. For this, let $(p,\alpha) \in T^*M$ and $v\in T_{(p,\alpha)}T^*M$. Now we compute
$G^*\theta_{(p,\alpha)}(v)=\theta_{(p, G_p\alpha)}(dG(v)) =G_p\alpha(d\pi(dG(v))).$
Our handy relation making this last part equal to $G_p\alpha(d\pi(v))$. If $G^*$ preserves $\theta$, then we must have equality $G_p\alpha(d\pi(v))=\alpha(d\pi(v))$ for all $v$, i.e. $G_p$ is the identity.