How to derive the two Friedmann-Lemaître equations from a Lagrangian?

Consider the Lagrangian of an isotropic-homogeneous spacetime (Robertson-Walker metric), containing a simple scalar field and a cosmological constant (this expression comes from the standard Hilbert-Einstein and scalar field action, in an isotropic-homogeneous spacetime) : \begin{equation}\tag{1} \mathcal{L} = -\: \frac{1}{8 \pi G} (3 \, a \, \dot{a}^2 - 3 k \, a + \Lambda \, a^3) + \frac{1}{2} \; \dot{\phi}^2 a^3 - \mathcal{V}(\phi) \, a^3. \end{equation} The function $\mathcal{V}(\phi)$ is the potential energy density of the scalar field. It's easy to find the differential equation of the scalar field from the Euler-Lagrange equation : \begin{equation}\tag{2} \frac{\partial \mathcal{L}}{\partial \, \phi} - \frac{d}{d t} \Big( \frac{\partial \mathcal{L}}{\partial \, \dot{\phi}} \Big) = 0 \quad \Rightarrow \quad \ddot{\phi} + 3 \frac{\dot{a}}{a} \, \dot{\phi} + \frac{d \mathcal{V}}{d \, \phi} = 0. \end{equation} For the scale factor $a$, Euler-Lagrange gives this equation : \begin{equation}\tag{3} \frac{\partial \mathcal{L}}{\partial \, a} - \frac{d}{d t} \Big( \frac{\partial \mathcal{L}}{\partial \, \dot{a}} \Big) = 0 \quad \Rightarrow \quad 2 \, \frac{\ddot{a}}{a} + \frac{\dot{a}^2}{a^2} + \frac{k}{a^2} = \Lambda - 8 \pi G \Big( \frac{1}{2} \, \dot{\phi}^2 - \mathcal{V}(\phi) \Big). \end{equation} This is actually a linear combination of the two Friedmann-Lemaître equations. The last part on the right is the scalar field pressure $p$. The FL equations are these (they are found by solving the Einstein's equation, instead of going the Lagrangian route) : \begin{gather}\tag{4} \frac{\dot{a}^2}{a^2} + \frac{k}{a^2} = \frac{8 \pi G}{3} \, \rho + \frac{\Lambda}{3}, \quad \text{(first Friedmann-Lemaître equ.)} \\[12pt] \frac{\ddot{a}}{a} = -\: \frac{4 \pi G}{3} (\rho + 3 \, p) + \frac{\Lambda}{3}, \quad \text{(second Friedmann-Lemaître equ.)} \tag{5} \end{gather}

Now, since equation (3) is a linear combination of equations (4) and (5), I want to find the other Friedmann-Lemaître equation. The Hamiltonian is easy to find : \begin{equation}\tag{6} \mathcal{H} \equiv \dot{a} \, \frac{\partial \mathcal{L}}{\partial \, \dot{a}} + \dot{\phi} \, \frac{\partial \mathcal{L}}{\partial \, \dot{\phi}} - \mathcal{L} = -\: \frac{3}{8 \pi G} \Big( \frac{\dot{a}^2}{a^2} + \frac{k}{a^2} - \frac{\Lambda}{3} \Big) \, a^3 + \Big( \frac{1}{2} \, \dot{\phi}^2 + \mathcal{V}(\phi) \Big) \, a^3. \end{equation} The last part on the right is the scalar field energy density $\rho$. The Hamiltonian (6) would give the first Friedmann-Lemaître equation (4) only if $\mathcal{H} = 0$.

So the question is this :

How to prove that the Hamiltonian (6) should be 0, using the Lagrangian (1) ?

EDIT : By deriving the Hamiltonian (6) and using equations (2) and (3), it's easy to verify that the Hamiltonian is conserved : \begin{equation}\tag{7} \frac{d \mathcal{H}}{d t} = 0 \quad \Rightarrow \quad \mathcal{H} = \textit{cste}. \end{equation} But how to prove that this constant is actually 0 ?

For (my) simplicity, I will keep $8\pi G=1$. Taking inspiration from this paper, I think it's possible to show what you ask only if you include explicitly also the lapse function $N$ in the FRW metric, like this: \begin{equation}\label{met} ds^2 = - N^2\, dt^2 + a^2(t)\, \frac{dr^2}{1-k\, r^2}+ r^2\, d\Omega^2\, , \end{equation} The associated Lagrangian would be \begin{equation}\label{lagr} \mathcal{L} = 3\, \left( N\, a\, k - \frac{a\, \dot{a}^2}{N} \right) + a^3 \left( \frac{\dot{\phi}^2}{2\, N} -N\, \mathcal{V}(\phi) \right)\, , \end{equation} with generalized coordinates $\{a,\phi,N\}$. The canonical momentum associated to $N$ is $p_N=0$, which means that actually $N$ is not a dynamical degree of freedom, and it equals a generic constant: that is why usually one writes the FRW metric without $N$, because the case $N=1$ can be achieved by a simple, and always allowed, redefinition of the metric time $N\, dt \rightarrow dt$ (one can say that it's a gauge choice).
Now, what happens if you want to try and get anyway the dynamics of the non-dynamical degree of freedom $N$? You can use Euler-Lagrange equations with the Lagrangian above and see that the result is \begin{equation}\label{fried} \frac{\partial\, \mathcal{L}}{\partial\, N} - \frac{d}{dt}\, \frac{\partial\, \mathcal{L}}{\partial\, \dot{N}} = 0\quad \Rightarrow\quad 3\, \frac{1}{N^2}\frac{\dot{a}^2}{a^2} + 3\, \frac{k}{a^2} -\frac{1}{2\, N^2}\dot{\phi}^2 - V(\phi) = 0\, . \end{equation} This looks already similar to (the Hamiltonian that you found) $\, =0$, the difference being, of course, the presence of $N$. But, as we saw, $N$ is a constant and we still have the gauge freedom to redefine the time variable: so you can simply redefine the time derivatives in the equation above with $N\, dt \rightarrow dt$ (which amounts to the gauge choice $N=1$) and find in this way the usual Friedmann equation.
The point is that, in some cases, it is good to have $N$ explicit because it makes evident the presence of a constraint: the trajectories in the phase space of this model are constrained on the energy surface $\mathcal{H}=0$, and Friedmann equation is an expression of such energy balance.