Let $\mathbf{q}$ be a complex vector of three elements defined as:
$$ \mathbf{q}:=\pmatrix{ E_x + iB_x\\ E_y + i B_y\\ E_z +i B_z } $$
I define the function $f(\mathbf{q})$:
$$ \begin{align} f(\mathbf{q})&=\mathbf{q}^T\mathbf{q}=\pmatrix{ E_x + iB_x& E_y + i B_y& E_z +i B_z }\pmatrix{ E_x + iB_x\\ E_y + i B_y\\ E_z +i B_z }\\ &=E_x^2+E_y^2+E_z^2-B_x^2-B_y^2-B_z^2+2i(E_xB_x+E_yB_y+E_zB_z)\\ &=||\mathbf{E}||^2-||\mathbf{B}||^2 +2i\mathbf{E}\cdot\mathbf{B} \end{align} $$
where $\mathbf{E}:=(E_x, E_y,E_z)$ and $\mathbf{B}:=(B_x,B_y,B_z)$.
The equation produces the Lorentz invariant of electromagnetism.
What is the invariance group of $f(\mathbf{q})\to f(O\mathbf{q})$ under a linear transformation $O$?
$$ \begin{align} f(O\mathbf{q})&=(O\mathbf{q})^T(O\mathbf{q})\\ &=\mathbf{q}^TO^TO\mathbf{q}\\ &\implies O^TO=I \end{align} $$
Consequently, since $Dim (\mathbf{q})$ is 3, we have $O(3)$.
I am a bit baffled as to why am I getting $O(3)$ here? I was expecting anything else; for instance $SO(3,1)$ or even $U(1)$, as the usual group associated with electromagnetism in the literature. Why are the Lorentz invariants of electromagnetism not Lorentz invariant but $O(3)$ invariant - where is the mistake?