Better than guessing the Lagrangian from the Equations of Motion, it is much more appealing to construct the Lagrangian from first principles.
Let me give you an example. If you want to describe the dynamics of a real spin 0 particle, you must first embed it into a field, namely the field $\phi$ you wrote, which is a Lorentz scalar. Because the Lagrangian (density) is Lorentz invariant, it contains all possible Lorentz invariant combinations of $\phi$ and derivatives of $\phi$. In order to obtain a linear differential Eq. we include only quadratic terms in $\phi$ in the Lagrangian; it is quite straightforward to see that$$\mathscr{L}=c_1 \partial_\mu\phi\partial_\mu\phi+c_2\phi^2$$is the only possibility, since $\phi$ does not possess any Lorentz structure. The coefficients are determined based on physical grounds and appropriate normalization.
For the Dirac Eq. this procedure is a bit more subtle, since the field $\Psi$ has a non-trivial representation of the Lorentz group, but the philosophy is the same. You can find this explicit construction in Schwartz's book, "Quantum Field Theory and the Standard Model", in chapter 10. Just to conclude, this procedure works for any spin (=Lorentz representation) you may desire; another good example you can find in Schwartz's book is the spin 2 case.