As AccidentalFourierTransform pointed out the answer is given in "The Classical Theory of Fields", L.D.Landau and E.M.Lifshitz, Fourth Revised English Edition. Copy-paste :
$\boldsymbol{\S}\: \textbf{2. Intervals}$
In what follows we shall frequently.......
...................
As already shown, if $\:ds=0\:$ in one inertial system, then $\:ds'=0\:$ in any other system. On the other hand, $\:ds\:$ and $\:ds'\:$ are infinitesimals of the same order. From these two conditions it follows that $\:ds^2\:$ and $\:ds'^{\,2}\:$ must be proportional to each other:
\begin{equation*}
ds^2=a ds'^{\,2}
\end{equation*}
where the coefficient $\:a\:$ can depend only on the absolute value of the relative velocity of the two inertial systems. It cannot depend on the coordinates or the time, since then different points in space and different moments in time would not be equivalent, which would be in contradiction to the homogeneity of space and time. Similarly, it cannot depend on the direction of the relative velocity, since that would contradict the isotropy of space.
Let us consider three reference systems $\:K,K_1,K_2\:$ and let $\:\boldsymbol{V}_{1}\:$ and $\:\boldsymbol{V}_{2}\:$ be the velocities of systems $\:K_1\:$ and $\:K_2\:$ relative to $\:K$. We then have :
\begin{equation*}
ds^2=a\left(\boldsymbol{V}_{1}\right) ds_{1}^{2}\,, \quad ds^2=a\left(\boldsymbol{V}_{2}\right)ds_{2}^{2}
\end{equation*}
Similarly we can write
\begin{equation*}
ds_{1}^{2}=a\left(\boldsymbol{V}_{12}\right)ds_{2}^{2} \,,
\end{equation*}
where $\:\boldsymbol{V}_{12}\:$ is the absolute value of the velocity of $\:K_2\:$ relative to $\:K_1$. Comparing these relations with one another, we find that we must have
\begin{equation}
\dfrac{a\left(\boldsymbol{V}_{2}\right)}{a\left(\boldsymbol{V}_{1}\right)}= a\left(\boldsymbol{V}_{12}\right).
\tag{2.5}\label{eq2.5}
\end{equation}
But $\:\boldsymbol{V}_{12}\:$ depends not only on the absolute values of the vectors $\:\boldsymbol{V}_{1}\:$ and $\:\boldsymbol{V}_{2}\:$, but also on the
angle between them. However, this angle does not appear on the left side of formula \eqref{eq2.5}.
It is therefore clear that this formula can be correct only if the function $\:a\left(\boldsymbol{V}\right)\:$ reduces to a constant, which is equal to unity according to this same formula.
Thus,
\begin{equation}
ds^2= ds'^{\,2}\,,
\tag{2.6}\label{eq2.6}
\end{equation}
and from the equality of the infinitesimal intervals there follows the equality of finite
intervals: $\:s=s'$.
Thus we arrive at a very important result: the interval between two events is the same in
all inertial systems of reference, i.e. it is invariant under transformation from one inertial
system to any other. This invariance is the mathematical expression of the constancy of the
velocity of light.