Solution (source code)

= Solution

Use the six-dimensional <vector space> of real symmetric $3\times3$ <matrices> as the target, rather than all nine matrix entries independently. Define
$$
F:M_3(\mathbb R)\longrightarrow\operatorname{Sym}_3(\mathbb R),\qquad F(A)=A^TJA-J.
$$
Its derivative is
$$
DF_A(H)=H^TJA+A^TJH.
$$
The given $J$ is symmetric with $J^2=I$. Every $A\in G$ is invertible, since taking determinants of $A^TJA=J$ gives $(\det A)^2=1$. For any symmetric target $S$, choose
$$
H=\tfrac12AJS.
$$
Then $A^TJH=\tfrac12JJS=S/2$, and its transpose is also $S/2$. Thus $DF_A(H)=S$ and the derivative is <surjective> at every point of $G$.

The <regular level set theorem> now gives
$$
\boxed{\dim G=9-6=3.}
$$
It also proves smooth embeddedness in the entire ambient <vector space> of <matrices>. The target symmetry is what gives the correct codimension.