You are right in saying that we cannot define a scalar potential for the Lorentz force since it's not conservative. However we can definitely write down vector and scalar potentials for the electric and magnetic fields from which we can construct a generalised potential.
Lagrangian mechanics is just a reformulation of your typical equations of motion. It doesn't matter if they are classical, quantum mechanical, relativistic or a completely made up local theory (there are limits). As long as you can guess a lagrangian whose Euler-Lagrange equations give you the correct equation of motion you are set. You can even account for friction or explicitly time-dependent forces with a Lagrangian as long as you can find the correct one even thought both of these are non conservative.
For the Lorentz force we can write down Newton's equations of motion very easily and then after some educated guesswork we can come up with a Lagrangian whose E-L equations produce this equation of motion. You can search up how to guess this lagrangian online but it looks something like, this.
$$\begin{align}
L&=\frac{1}{2}mv^2+q\vec{v}\cdot\vec{A}-q\phi \\
\vec{F}&=q(\vec{E}+\vec{v}\times\vec{B})
\end{align} \\
\text{Here $\vec{A}$ is the vector potential and $\phi$ is the scalar potential}$$
Now that you have the Lagrangian you can construct the Hamiltonian and you can even put hats on everything to do quantum mechanics (this might seem weird to you but remember that you just put hats on your conservative hamiltonians to start doing qm anyways). Now if you analyze this Lagrangian/Hamiltonian you will quickly figure out that momentum doesn't look like momentum, and the potential doesn't look like a potential and your whole idea of $L = T-V$ breaks down. But none of that matters because it gives you the correct equations of motions so it is correct physics and we can get down to using it.