Focusing on the theory of your specific case, and avoiding the more general discussions, here is how one could derive the Hamiltonian after a change of (curvilinear) coordinates. The beauty of Lagrangian mechanics is that it is covariant with respect to any change of coordinates, both related to inertial and non-inertial alike. This fact comes from the principle of least action formulation. If $L$ is the Lagrangian of a system (the Lagrangian doesn't have to be unique; as long as the critical value equation is the same for two different Lagrangians, they describe the same dynamics) the action functional associated with $L$ is
$$S[q] = \int_{t_1}^{t_2} L\big(q(t), \dot{q}(t), t\big) dt$$ for curves $q(t)$ defined for $t\in [t_1,t_2]$ such that $q(t_1) = q_1$ and $q(t_2) = q_2$ are two fixed points. Then for an arbitrary one parameter family of curves $q(t,s)$ (the so called variation of the curves) fixed at $q_1$ and $q_2$ we get
$$S[q](s) = \int_{t_1}^{t_2} L\big(q(t,s), \partial_t {q}(t,s), t\big) dt$$ so the critical curves, which are the trajectories of the dynamics, should satisfy the "zero functional gradient" condition, also known as principle of least action
$$\delta S[q] = \frac{\partial}{\partial s} \, S[q](s)\,{\Big|_{s=0}} = 0$$ which is equivalent to the Euler-Lagrange equations
$$\frac{d}{dt}\, \left(\frac{\partial L}{\partial \dot{q}}\big(q,\dot{q},t\big) \right)= \frac{\partial L}{\partial {q}}\big(q,\dot{q},t\big) $$ Therefore, if you change the coordinates $q,t$ to $Q,\tau$ of the integral one-form
${L}\big(q,\dot{q},t\big)dt$ to obtain a new one form $\tilde{L}\big(Q,\dot{Q},\tau\big)d\tau$, where $\dot{Q} = \frac{d Q}{d\tau}$, the integral and thus $ S[q] = S[Q]$ so $\delta S[q] = \delta S[Q] = 0$ which means that the equations $$\frac{d}{dt}\, \left(\frac{\partial L}{\partial \dot{q}}\big(q,\dot{q},t\big) \right)= \frac{\partial L}{\partial {q}}\big(q,\dot{q},t\big) \,\,\, \text{ and } \,\,\, \frac{d}{d\tau}\, \left(\frac{\partial \tilde{L}}{\partial \dot{Q}}\big(Q,\dot{Q},\tau\big) \right)= \frac{\partial \tilde{L}}{\partial {Q}}\big(Q,\dot{Q},\tau\big) $$ describe the same solutions but in different coordinates and possibly parametrized differently. In your case however, $\tau = t$ so it is enough to change the variables from $q$ to $Q$, while keeping the time $t$ parametrization the same, of the Lagrange function ${L}\big(q,\dot{q},t\big)$ to obtain the Lagrange function $\tilde{L}\big(Q,\dot{Q},t\big)$ in the new coordinates.
In your case the change of variables is $Q = f(q,t)$, so $$\dot{Q} = D_q f(q,t) \dot{q} + \partial_t f(q,t)$$ thus
$${L}\big(q,\dot{q},t\big) = \tilde{L}\Big(f(q,t),\, D_q f(q,t) \dot{q} + \partial_t f(q,t), \, t\Big)$$ The Euler-Lagrange equations with $L$ turn into the equations with $\tilde{L}$ and you are done (of course, you are allowed to manipulate the new Lagrangian $\tilde{L}$ by integrating by parts in the action $S[Q]$, if possible, to get an equivalent Lagrnagian, but that is not necessary).
Now, the Hamiltonian picture. Recall the duality between Lagrangians and Hamiltonians:
\begin{align*}
{L}\big(q,\dot{q},t\big) &= p\cdot\dot{q} - H\big(q,p ,t\big)\\
\tilde{L}\big(Q,\dot{Q},t\big) &= P\cdot\dot{Q} - \tilde{H}\big(Q,P,t\big)
\end{align*} Since $${L}\big(q,\dot{q},t\big) = \tilde{L}\big(Q,\dot{Q},t\big) = \tilde{L}\Big(f(q,t),\, D_q f(q,t)\dot{q} + \partial_t f(q,t), \, t\Big) $$ we get that
$$ p\cdot\dot{q} - H\big(q,p ,t\big) = P\cdot\dot{Q} - \tilde{H}\big(Q,P,t\big)$$ Moreover, for the conjugate momenta we have
\begin{align}
p &= \frac{\partial L}{\partial \dot{q}}\big(q,\dot{q},t\big)\\
P&=\frac{\partial \tilde{L}}{\partial \dot{Q}}\big(Q,\dot{Q},t\big)
\end{align} so for $p$ we have
$$p =\frac{\partial}{\partial \dot{q}} L\big(q,\dot{q},t\big) = \frac{\partial}{\partial \dot{q}} \tilde{L}\Big(f(q,t),\, D_q f(q,t)\dot{q} + \partial_t f(q,t), \, t\Big) = \Big(D_qf(q,t)\Big)^*\frac{\partial \tilde{L}}{\partial \dot{Q}} = \Big(D_qf(q,t)\Big)^* P$$ where the $*$ superscript means transposed of the linear transformation $D_qf(q,t)$ so $$P = \Big(D_qf(q,t)^*\Big)^{-1} p$$ Thus
\begin{align}
p\cdot\dot{q} - H\big(q,p ,t\big) &= P\cdot\dot{Q} - \tilde{H}\big(Q,P,t\big)\\
&= \Big( \, \Big(D_qf(q,t)^*\Big)^{-1} p \Big) \cdot\Big( D_q f(q,t)\dot{q} + \partial_t f(q,t)\Big) - \tilde{H}\Big(f(q,t),P,t\Big)\\
&= p \cdot\Big( \big(D_qf(q,t)\big)^{-1} \big(\, D_q f(q,t)\dot{q} + \partial_t f(q,t) \, \big)\Big) - \tilde{H}\Big(f(q,t),P,t\Big)\\
&= p \cdot\Big(\dot{q} +\big(D_qf(q,t)\big)^{-1} \partial_t f(q,t) \, \big)\Big) - \tilde{H}\Big(f(q,t),P,t\Big)\\
&= p \cdot \dot{q} + p \cdot \Big(\big(D_qf(q,t)\big)^{-1} \partial_t f(q,t) \, \big)\Big) - \tilde{H}\Big(f(q,t),P,t\Big)\\
&= p \cdot \dot{q} - \Big[ \, \tilde{H}\Big(f(q,t),P,t\Big) - p \cdot \Big(\big(D_qf(q,t)\big)^{-1} \partial_t f(q,t) \, \big)\Big) \, \Big]
\end{align} which after cancelling the common terms $p\cdot \dot{q}$ on both sides of the equation yields $$ H\big(q,p ,t\big) = \tilde{H}\Big(f(q,t),P,t\Big) - p \cdot \Big(\big(D_qf(q,t)\big)^{-1} \partial_t f(q,t) \, \big)\Big)$$
$$\tilde{H}\Big(f(q,t),P,t\Big) = H\big(q,p ,t\big) + p \cdot \Big(\big(D_qf(q,t)\big)^{-1} \partial_t f(q,t) \, \big)\Big)$$
$$\tilde{H}\Big(f(q,t), \big(D_qf(q,t)^*\big)^{-1} p, t\Big) = H\big(q,p ,t\big) + p \cdot \Big(\big(D_qf(q,t)\big)^{-1} \partial_t f(q,t) \, \big)\Big)$$ $$\tilde{H}\Big(f(q,t), P, t\Big) = H\big(q,p ,t\big) + \Big( \big(D_qf(q,t)^*\big)^{-1} p \Big) \cdot \Big(\partial_t f(q,t) \, \big)\Big)$$ $$\tilde{H}\Big(f(q,t), P, t\Big) = H\big(q,p ,t\big) + P \cdot \Big(\partial_t f(q,t) \, \big)\Big)$$ This is where the link between the two Hamiltonians come from. One can phrase it in terms of generating functions of canonical transformations. Let $G(q,P,t) = P \cdot f(q,t)$. Then $$Q = \frac{\partial G}{\partial P}\big(q, P, t\big) = f(q,t)\, ,\,\,\,\,\,\, p = \frac{\partial G}{\partial q}\big(q, P, t\big)$$ $$\frac{\partial G}{\partial t}\big(q,P,t\big) =
\frac{\partial}{\partial t} \big( P \cdot f(q,t) \big) = P \cdot \partial_t
f(q,t)$$
Thus the identity between the two Hamiltonians becomes
$$\tilde{H}\Big(f(q,t), P, t\Big)
=
H\Big(q, \frac{\partial G}{\partial q} ,t\Big) +
P \cdot \Big(\partial_t f(q,t) \, \big)\Big)$$
$$\tilde{H}\left(\frac{\partial G}{\partial P}, P, t\right)
=
H\left(q, \frac{\partial G}{\partial q} ,t\right) +
\frac{\partial G}{\partial t}$$
In your case $Q = f(q,t) = q - x(t)$ so
$$G\big(q, P, t\big) = P \cdot \big(q - x(t)\big) =
P \cdot q - P \cdot x(t)$$ and thus $$P = p \,\,\,\, Q = q - x(t)$$
Let me put $m=1$ for simplicity.
The original Hamiltonian is $$H = \frac{1}{2} p^2 +
V\big(q-x(t)\big)$$ and
$$\frac{\partial G}{\partial t} =
\frac{\partial }{\partial t} \, P \cdot \big(q - x(t)\big)
= - P \cdot \dot{x}(t)$$
Thus $$\tilde{H} = \frac{1}{2} P^2 +
V\big(Q\big) - P \cdot \dot{x}(t)$$ which yields the Hamiltonian
equations
\begin{align*}
\dot{Q} &= P - \dot{x}(t)\\
\dot{P} & = - \nabla\, V(Q)
\end{align*} so
$$\ddot{Q} = \dot{P} - \ddot{x}(t) = - \nabla\, V(Q) - \ddot{x}(t)$$
$$\ddot{Q} + \ddot{x}(t) = - \nabla\, V(Q) $$ which hare the
Euler-Lagrange equations of the Lagrangian
$$\tilde{L} = \frac{1}{2}\big(\dot{Q} + \dot{x}(t)\big)^2 - V(Q)$$
I think my underlying issue was being uncomfortable actually evaluating the action integral and arriving at a different Lagrangian, which leads to my Hamiltonian. However, it appears that evaluating (or partially evaluating) the action integral via IBP yields an equally valid Lagrangian which results in the same EOM. So long as the EOM remain unchanged, it is not an issue?
– QtizedQ Apr 29 '17 at 18:17