Hamiltonian for relativistic free particle is zero

...what I would like to know is why we get a zero Hamiltonian. I suspect that this is due to the reparametrization invariance... Will this always happen? Why?

Yes, it is due to reparameterization invariance. In other words, the zero-Hamiltonian result holds for any reparameterization-invariant action, not just for the relativistic particle. In this sense, the answer to "Will this always happen" is yes. And one way to answer the "Why?" question is to give a general proof. That's what I'll do here.

I'll denote the parameter as $t$ instead of $\lambda$, because it's easier to type.

Consider any model with an action of the form $$ S=\int dt\ L(t) \hskip2cm L(t) = L\big(\phi(t),\dot\phi(t)\big) \tag{1} $$ where $\phi_1(t),\phi_2(t),...$ is a collection of dynamic variables. If the action is invariant under rigid translations in $t$, then Noether's theorem gives us a corresponding conserved quantity: the Hamiltonian. If the action is invariant under reparameterizations in $t$, then we might expect to get a stronger result because of the more extreme symmetry, and we do: the conservation law still holds, but the conserved quantity is identically zero (and therefore useless). The goal is to prove that the larger symmetry leads to this stronger result.

Suppose that the action is invariant under all transformations of the form $$ \phi_n(t)\rightarrow\phi_n(t+\epsilon) \tag{2} $$ where $\epsilon(t)$ is allowed to be any smooth function for which the map $t\rightarrow t+\epsilon(t)$ is invertible. This is reparameterization invariance. For infinitesimal $\epsilon$, \begin{equation} \delta\phi_n(t) = \dot\phi_n(t)\epsilon. \tag{3} \end{equation} Take the derivative of this with respect to $t$ to get \begin{equation} \delta\dot\phi_n(t) = \frac{d}{dt}\Big(\dot\phi_n(t)\epsilon\Big). \tag{4} \end{equation} Now consider the identity \begin{equation} \delta S = \int dt\ \delta L \tag{5} \end{equation} with \begin{equation} \delta L = \sum_n\left( \frac{\partial L}{\partial \phi_n}\delta\phi_n + \frac{\partial L}{\partial \dot\phi_n}\delta\dot\phi_n \right), \tag{6} \end{equation} which is valid for any transformation of the $\phi$s. For the particular transformation (3)-(4), equations (4)-(5) become \begin{equation} \delta S = \sum_n\int dt\ \left(\frac{\partial L}{\partial \phi_n}\dot\phi_n\epsilon + \frac{\partial L}{\partial \dot\phi_n}\frac{d}{dt}(\dot\phi_n\epsilon) \right). \tag{7} \end{equation} Compare this to the identity $$ \frac{d}{dt}(L\epsilon) = \sum_n\left(\frac{\partial L}{\partial \phi_n}\dot\phi_n + \frac{\partial L}{\partial \dot\phi_n}\frac{d}{dt}\dot\phi_n\right)\epsilon + L\frac{d}{dt}\epsilon \tag{8} $$ to see that (7) may also be written \begin{equation} \delta S = \int dt\ \left(\frac{d}{dt}(L\epsilon) + \left[\sum_n\frac{\partial L}{\partial \dot\phi_n}\dot\phi_n-L\right] \frac{d}{dt}\epsilon \right). \tag{9} \end{equation} For any finite integration interval, the first term is zero if $\epsilon(t)$ is zero at the endpoints of the integration interval. Since $d\epsilon/dt$ is arbitrary within this interval, and since this holds for any interval, the invariance of the action ($\delta S=0$) implies that the quantity in square brackets must be zero. The quantity in square brackets is the Hamiltonian, so this completes the proof that the Hamiltonian is identically zero in this class of models.

Here's another way:

Suppose that your lagrangian has the following property, for any $\theta$ (it could be a function of time $t$): \begin{equation}\tag{1} L(q, \, \theta \, \dot{q}) = \theta \, L(q, \, \dot{q}). \end{equation} This implies that the action \begin{equation}\tag{2} S = \int_{t_1}^{t_2}L(q, \, \dot{q}) \, dt \end{equation} is invariant under a reparametrisation of time : $t \, \Rightarrow \, \tau(t)$ which doesn't change the integration limits : $\tau(t_1) = t_1$ and $\tau(t_2) = t_2$. Then, using (1), you could write the following: \begin{equation}\tag{3} \frac{d\,}{d\theta} \, L(q, \, \theta \, \dot{q}) \Big|_{\theta = 1} = \dot{q} \, \frac{\partial L}{\partial \dot{q}} \equiv L(q, \, \dot{q}), \end{equation} which implies a vanishing hamiltonian: \begin{equation}\tag{4} H = \dot{q} \, \frac{\partial L}{\partial \dot{q}} -L = 0. \end{equation} This applies to your lagrangian for a relativistic particle, with $q \rightarrow x^{\mu}$ and $t \rightarrow \lambda$.

  1. Infinitesimal world-line (WL) reparametrization transformations $$ t^{\prime} - t ~=:~\delta t ~=~-\varepsilon(t), \qquad \text{(horizontal variation)}\tag{A}$$ $$ q^{\prime j}(t) - q^j(t)~=:~\delta_0 q^j(t) ~=~\varepsilon(t)\dot{q}^j(t), \qquad \text{(vertical variation)}\tag{B}$$ $$ q^{\prime j}(t^{\prime}) - q^j(t)~=:~\delta q^j(t) ~=~0. \qquad \text{(full variation)}\tag{C}$$ are gauge/local/$t$-dependent transformations, which is stickly speaking the realm of Noether's second theorem. This leads to an off-shell Noether identity (L).

  2. In contrast, Noether's first theorem in its basic formulation considers global/$t$-independent transformations. (For the related proof of on-shell energy conservation via global time translation symmetry, see e.g. my Phys.SE answer here.) However in OP's case, there is a $t$-dependent trick. Straightforward standard calculations reveal that the infinitesimal variation of the action $$S~=~\int_I\!dt~ L\tag{D}$$ is of the form $$ \delta S~=~\int_I\!dt~ (\varepsilon k + h \dot{\varepsilon}), \tag{E}$$ for some function $k$, where the energy function $$h~:=~p_j\dot{q}^j-L, \qquad p_j~:=~\frac{\partial L}{\partial \dot{q}^j}, \tag{F}$$ is the Noether charge.

  3. Case if the transformation (A)-(C) is a strict off-shell symmetry: If the infinitesimal variation (E) has no boundary contributions, we must have $$\varepsilon k + h \dot{\varepsilon}~\equiv~0\tag{G}$$ off-shell. Taking $\varepsilon$ to be $t$-independent we see that $$k~\equiv~ 0.\tag{H}$$ Comparing with eq. (G), we get OP's sought-for conclusion

    $$h~\equiv~ 0.\tag{I}$$

    In other words, the Lagrangian $L$ is a homogeneous function of the generalized velocities $\dot{q}$ of weight 1, cf. Cham's answer. We shall later see via eq. (L) that eq. (I) also implies that the Lagrangian $L$ has no explicit time dependence. In this case the action (D) is manifestly WL reparametrization invariant.

  4. Case if the transformation (A)-(C) is an off-shell quasi-symmetry: It turns out that $$k~\equiv~ \frac{\delta S}{\delta q^j}\dot{q}^j + \dot{h}, \tag{J}$$ so that the infinitesimal variation (E) is $$\delta S~=~\int_I\!dt~ (\varepsilon \frac{\delta S}{\delta q^j}\dot{q}^j + \frac{d(h\varepsilon)}{dt}).\tag{K}$$ Even if we allow possible total time derivative contributions in the infinitesimal variation (K), we still get an off-shell Noether identity

    $$0~\equiv~-\frac{\delta S}{\delta q^j}\dot{q}^j~\equiv~(\dot{p}_j-\frac{\partial L}{\partial q^j})\dot{q}^j~\equiv~\frac{d(p_j\dot{q}^j)} {dt}-(\frac{\partial L}{\partial q^j}\dot{q}^j+\frac{\partial L}{\partial \dot{q}^j}\ddot{q}^j)$$ $$~\equiv~\frac{d(p_j\dot{q}^j)} {dt}-(\frac{dL}{dt}-\frac{\partial L}{\partial t})~\equiv~\frac{dh}{dt}+\frac{\partial L}{\partial t}.\tag{L} $$

    Example 1: If $L(q,\dot{q})$ has no explicit time-dependence, then the energy (F) has no explicit time-dependence. From the off-shell identity (L) $$ 0~\equiv~\frac{dh(q,\dot{q})}{dt}~=~\frac{\partial h(q,\dot{q})}{\partial q^j}\dot{q}^j+\frac{\partial h(q,\dot{q})}{\partial \dot{q}^j}\ddot{q}^j,\tag{M}$$ we deduce that the energy $h$ must be a global constant independent of all the variables $(q,\dot{q},t)$.

    Example 2: If $L(t)$ does not depend on $q$ and $\dot{q}$, then the action $S$ has a quasi-symmetry under the transformation (A)-(C), and the energy is $h(t)=-L(t)$.