The following code
\documentclass{article}
\usepackage[dvipsnames]{xcolor}
\usepackage{colortbl}
\definecolor{myGray}{HTML}{F2F2F2}
\newcolumntype{G}{>{\columncolor{myGray}\centering$}m{6mm}<{$}}
\newcolumntype{M}{>{\centering$}m{6mm}<{$}}
\newcolumntype{C}{>{$}c<{$}}
\begin{document}
\begin{tabular}{|G|M|M|M|M|}
\hline
\rowcolor{myGray} \times & 1 & i & j & k \\hline
1 & 1 & i & j & k \\hline
i & i & -1 & k & -j \\hline
j & j & -k & -1 & i \\hline
k & k & j & -i & -1 \\hline
\end{tabular}
\end{document}
creates this error message:
! LaTeX Error: There's no line here to end.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.13 ...rowcolor{myGray} \times & 1 & i & j & k \
\hline
When I modified the alignment of the table from {|G|M|M|M|M|} to {|G|M|M|M|m|}, it does work. But I think that the definition of M isn't wrong.

arraypackage (to enable the macro\newcolumntype) and (b) replace both instances of\centeringwith\centering\arraybackslash. Separately, do also replace\usepackage[dvipsnames]{xcolor} \usepackage{colortbl}with\usepackage[dvipsnames,table]{xcolor}in order to assure optimal interoperability of thexcolorandcolortblpackages. – Mico Jul 17 '22 at 05:41