Naively, we can conjecture that Lagrangian of charged particle in EM field is $$L = \frac{1}{2}m \mathbf{v}^2 - q\varphi\tag{1}$$ where $\varphi$ is scalar potential. But it is known that this is not true and under gauge transform $$\mathbf{A} \rightarrow \mathbf{A} + \nabla \chi, \quad \varphi \rightarrow \varphi - \frac{\partial \chi}{\partial t}.\tag{2}$$ This Lagrangian transforms like $$L \rightarrow \frac{1}{2}m \mathbf{v}^2 - q\varphi + q\frac{\partial \chi}{\partial t}.\tag{3}$$ I think this does not affect underlying physics because the last term is total derivative wrt time and in terms of action, total derivative of some function doesn't give anything.
True Lagrangian of given system is $$L = \frac{1}{2}m \mathbf{v}^2 + q\mathbf{v}\cdot\mathbf{A} - q\varphi\tag{4}$$ where $\mathbf{A}$ is a vector potential. Under the same transformation, this Lagrangian transforms like $$L \rightarrow \frac{1}{2}m \mathbf{v}^2 + q\mathbf{v}\cdot\mathbf{A} - q\varphi + q\frac{d\chi}{dt}.\tag{5}$$ The last term is also total derivative wrt time which does not give anything when we compute action.
Under which gauge we treat this Lagrangian?
And can we say that this Lagrangian is gauge invariant?
I know that the first Lagrangian (1) can't give us Lorentz force but second one (4) can do.