The derivation of wave equation that you alluded in your question can be adapted to derive Maxwell equations. Perhaps, the best exposition of this technique is given by J.D. Jackson in section 12.7 of his 'Classical Electrodynamics' (3rd edition). It is so lucid that I reproduce it as is below.
The Lagrangian approach to continuous fields closely parallels the
techniques used for discrete point particles. The finite number of
coordinates $q_i(t)$ and $\dot{q}_i(t)$, $i = 1, 2, \ldots n$, are
replaced by an infinite number of degrees of freedom. Each point in
space time $x^\alpha$ corresponds to a finite number of values of the
discrete index $i$. The generalized coordinate $q_i$ is replaced by a
continuous field $\phi_k(x)$, with a discrete index ($k = 1, 2,
\ldots, n$) and a continuous index $x^\alpha$. The generalized
velocity $\dot{q}_i$ is replaced by the $4$-vector gradient
$\partial^\beta\phi_k$. The Euler-Lagrange equations follow from the
stationary property of the action integral with respect to variations
$\delta\phi_k$ and $\delta(\partial^\beta\phi_k)$ around the physical
values. We thus have the following correspondences: $i \rightarrow
x^\alpha, k$, $q_i \rightarrow \phi_k(x)$, $\dot{q}_i \rightarrow
\partial^\alpha\phi_k(x)$,
\begin{equation} L = \sum_i L_i(q_i, \dot{q}_i) \rightarrow \int\mathcal{L}(\phi_k, \partial^\alpha\phi_k)d^x
\end{equation}
and
\begin{equation}
\frac{d}{dt}\left(\frac{\partial L}{\partial\dot{q}_i}\right) =
\frac{\partial L}{\partial q_i} \rightarrow
\partial^\beta\frac{\partial\mathcal{L}}{\partial(\partial^\beta\phi_k)}
= \frac{\partial\mathcal{L}}{\partial\phi_k},
\end{equation}
where $\mathcal{L}$ is a Lagrangian density, corresponding to a definite
point in space-time and equivalent to the individual terms in a
discrete particle Lagrangian. For the electromagnetic field, the
"coordinates" and "velocities" are $A^\alpha$ and $\partial^\beta
A^\alpha$.
I think this paragraph beautifully summarizes how one can go from masses-with-springs to field-equations and how to use the latter to get a Lagrangian description of the electromagnetic fields.
Jackson further writes
In analogy with the situation with discrete particles, we expect the free-field Lagrangian at least to be quadratic in the velocities, that is, $\partial^\beta A^\alpha$ or $F^{\alpha\beta}$, the electromagnetic field tensor.
Lastly, he also argues for a term $J_\alpha A^\alpha$ to account for the interaction of charged particles with electromagnetic fields. You may want to go over the rest of the section for his derivation of the inhomogeneous Maxwell equations. (The homogeneous ones follow from the definition of $F^{\alpha\beta}$.)
Before closing let me add that I could not find a mass-with-springs analogy in volume 1 of Maxwell's treatise on electricity and magnetism. In fact, his derivation (article 76) of Gauss law is similar to what we find in modern textbooks, except that he calls $R$ the magnitude of the electric field.