In Classical Mechanics, a gauge transformation is of the form \begin{equation} L \to L' = L + \frac{dF(q,t)}{dt} \, . \end{equation} Any transformation of this kind leaves the Euler-Lagrange equation invariant since the additional term $\frac{dF(q,t)}{dt}$ here simply drops out.
In contrast, the Euler-Lagrange equation is, in general, only covariant under point transformations $q \to Q=Q(q,t)$. Concretely, the Euler-Lagrange equation reads in the original coordinates \begin{equation} \frac{\partial \mathcal{L}(q,\dot q,t)}{\partial q}= \frac{d}{dt}\left(\frac{\partial \mathcal{L}(q,\dot q,t)}{\partial \dot{q}}\right) \end{equation} and in terms of the new coordinates \begin{equation} \frac{\partial \mathcal{L}'(Q,\dot Q,t)}{\partial Q}= \frac{d}{dt}\left(\frac{\partial \mathcal{L}'(Q,\dot Q,t)}{\partial \dot{Q}}\right) \end{equation} But, in general, we have $$ \mathcal{L}'(Q,\dot Q,t) \neq \mathcal{L}(Q,\dot Q,t) \, .$$ Therefore, under a general coordinate transformations the Euler-Lagrange equation keeps its form but is not invariant.
Now, in the Hamiltonian formalism we consider phase space transformations and usually focus on canonical transformations. The defining condition of canonical transformation is Hamilton's equations keep their form, i.e. is covariant.
However, in a second step, canonical transformations are usually discussed using so-called generating functions. These show up if we derive Hamilton's equations using the least-action principle for the Hamiltonian Lagrangian $$ L_H = p \dot q- H \,. $$ The main argument is that if we want to end up with the same equation if we switch coordinates, we have the condition $$ L_H - L_H' = \frac{dF}{dt} $$ $$ \therefore \quad p \dot q- H - (P \dot Q- K) = \frac{dF}{dt} \, , $$ where $K= H(q(Q,P),p(Q,P)$ is the Hamiltonian in terms of the new coordinates $Q,P$. In words, this means that a transformation $q,p \to Q,P$ which leads to at most a change in the Lagrangian Hamiltonian which can be written as a total derivative, yields same Hamilton equations.
However, as far as I understand it, this is a extremely strict condition which only includes transformation that leave Hamilton's equation invariant. But, as argued above, a general canonical transformation is only required to leave the form of Hamilton's equations unchanged.
Therefore my question: Can all canonical transformations be generated using a generating function?
Following my reasoning above, it seems that since for general canonical transformations we only require the covariance of Hamilton's equations, these are not included in the generating function analysis which is based on the condition that Hamilton's equations are invariant.