Consider an optimal control problem written in a Mayer form $$ \min_{u(\cdot)\in L^\infty([0,T])} \varphi(x_u(T)) $$ where the state $x_u\in \mathbb{R}^n$ associated to the control $u$ satisfies $$ \dot x(t) = f(x(t),u(t)), \; \forall t\in [0,T] a.e. $$ and $\varphi:\mathbb{R}^b\to \mathbb{R}$ is the cost function.
From the Pontryagin maximum principle, if $(x,u)$ is optimal then there exists a unqie (up to a multiplicative constant) $p:[0,T]\to \mathbb{R}^n$ solution of the system $$ \dot x = \frac{\partial H}{\partial p},\; \dot p = -\frac{\partial H}{\partial x},\; \max_{u} H(x,p,u) = M(x,p) \qquad (*) $$ where $H$ is the Hamiltonian defined as $ H(x,p,u) = p\cdot f(x,u) $, and $M$ is a nonnegative constant along $(x,p)$. Moreover the transversality condition $$ p(T) = -\frac{\partial \varphi}{\partial x}(x(T)) \qquad (**) $$ should be satisfied. I call $(x,p,u)$ an extremal if it satisfies $(*)$ and $(**)$.
My question is: is it possible to find an optimal control problem and an extremal $(x,p,u)$ such that $p\equiv 0$ ?
Clearly, we must have $-\frac{\partial \varphi}{\partial x}(x(T))=0$
Yes, this is possible under a few conditions.
$$ \frac{\partial \phi}{\partial x(T)} = 0 $$
$$ \dot{p} = -\frac{\partial H}{\partial x} = 0 $$
$$ \psi = \phi + \nu_1(x(0) - x_0) + \nu_2(x(T) - x_T) $$
You would need both $x_0 = x_T = 0$ in general. If boundary conditions on $x$ are free, then you discover you can choose pretty much any value for $p$, which then 0 becomes the obvious choice given your goal. I'll admit, however, that I'm a little less familiar with point 3 and I probably missed some details.
Those are the conditions, now to find an optimal control problem where this is the case. Consider a spacecraft performing an orbit raising maneuver maximizing final radius:
$$ \begin{aligned} \min_{\alpha} J &= -r^2 \\ \text{Subject to:} \; r &= v_r \\ \dot{\theta} &= \frac{v_{\theta}}{r} \\ \dot{v_r} &= \frac{v_{\theta}^2}{r} - \frac{\mu}{r^2} + \frac{\text{Thrust}}{m}\cos(\alpha) \\ \dot{v_{\theta}} &= -\frac{v_r v_{\theta}}{r} + \frac{\text{Thrust}}{m}\sin(\alpha) \\ \dot{m} &= m_{rate} \\ r(0) &= r_0, \theta(0) = \theta_0, v_r(0) = v_{r0}, v_{\theta} = v_{\theta 0} \\ m(0) &= m_0, v_r(T) = v_{rf}, v_{\theta}(T) = \sqrt{\mu / r} \end{aligned} $$
In this case, you can fix $\theta(0)$ to anything. Also, since $\theta$ doesn't appear in the Hamiltonian, then $p_\theta$ is 0 for all time.