You really really really don't want to do this.
But if you did want to do it, then you could do this, but you just know it's bound to break something.

\documentclass{article}
\usepackage{comma}
\def\commaformtoken{\,}
\edef\mca{\the\mathcode`0\space}
\edef\mcb{\the\mathcode`1\space}
\edef\mcc{\the\mathcode`2\space}
\edef\mcd{\the\mathcode`3\space}
\edef\mce{\the\mathcode`4\space}
\edef\mcf{\the\mathcode`5\space}
\edef\mcg{\the\mathcode`6\space}
\edef\mch{\the\mathcode`7\space}
\edef\mci{\the\mathcode`8\space}
\edef\mcj{\the\mathcode`9\space}
\def\normaldigits{%
\mathcode`\0=\mca
\mathcode`\1=\mcb
\mathcode`\2=\mcc
\mathcode`\3=\mcd
\mathcode`\4=\mce
\mathcode`\5=\mcf
\mathcode`\6=\mcg
\mathcode`\7=\mch
\mathcode`\8=\mci
\mathcode`\9=\mcj
}
\newcount\hmmcnt
\makeatletter
\def\hmmdef#1{%
\bgroup\lccode`\~`#1\lowercase{\egroup
\count@\mathcode`~
\mathcode`~="8000
\edef~{%
\bgroup
\noexpand\normaldigits
\afterassignment\noexpand\hummcomma\hmmcnt#1}}}
\def\hummcomma{\@commaform\hmmcnt\egroup}
\def\activedigits{
\hmmdef0
\hmmdef1
\hmmdef2
\hmmdef3
\hmmdef4
\hmmdef5
\hmmdef6
\hmmdef7
\hmmdef8
\hmmdef9
}
\makeatother
\begin{document}
\activedigits
\[123456 = \frac{1234560}{10} \]
\normaldigits
\[123456 = \frac{1234560}{10} \]
\activedigits
\[123456 = \frac{1234560}{10} \]
\end{document}
siunitx update:
If you'd rather use siunitx rather than comma package to do the spacing then change
the package loading, and change
\def\hummcomma{\@commaform\hmmcnt\egroup}
to
\def\hummcomma{\num{\the\hmmcnt}\egroup}
basic idea of code
to turn 123 into \num{123} the idea is fairly simple.
give each digit an active definition so that, say, 1 is equivalent to \aftarassignment\helper\count@1
TeX then starts to assign a number to \count@ so it gobbles up all following digits until it gets to a non-digit leaving the value in \count@ (and failing if that number is too big).
The \afterassignment primitive then re-inserts the \helper token to expand, so this can now access the number from the count register as \the\count@ so \expandafter\num\expandafter{\the\count@} is the same as \num{123}
There is a slight problem in that the above description doesn't work, as you don't know which digit will be first, so you have to make all digits have mathcode "8000 and all have active definitions. But they would still have those definitions when the digits were re-inserted by executing \the\count@ which would put you in an infinite loop. So the definition has to start a local group, within that group re-define each digit to typeset its normal \mathcode specified character, and then finally after applying the spacing command, end the group. The \mc? commands are the saved mathcodes for each of the digits, and \hmmdef sets up the digit specified in its argument to have the right mathcode and active definition. \hmmcomma is the helper token inserted by \aftergroup that actually does the spacing of every third digit, using siunitx or comma packages.
update changed the grouping to use \bgroup rather than \begingroup as the latter does not work with x^2 you have to use the official LaTeX syntax x^{2}.
$1234 x$will be converted to<mnum> 123 </mnum> <...>x</...>(sorry don't remember MathML tags on top of my head. Of course the parser is written in Lua and, in principle, adding a output formatter for PDF output is easy. – Aditya May 30 '12 at 15:31\,separators manually is often easier than writing\num{}. – Nagel Apr 03 '14 at 10:31