The question can be formulated as following:
Suppose $$\delta \int_{t_1}^{t_2}{[p\cdot \dot{q} - H(p,q,t) ]dt} = 0$$ $$\delta \int_{t_1}^{t_2}{[P\cdot \dot{Q} - K(P,Q,t) ]dt} = 0$$
in which $$P = P(p,q,t), Q = Q(p,q,t)$$ is an invertible transformation.
Can we prove that there must exist a $\lambda$ and function $G(p,q,t)$ (or $G(p,Q,t)$, $G(P,Q,t)$, $G(P,q,t)$), such that $$\lambda[p\cdot \dot{q} - H(p,q,t) ] = [P\cdot \dot{Q} - K(P,Q,t) ] + \frac{dG}{dt}~?$$