You probably won't be able to do this the way you planned. Probably what you want is to use the Matrix MathObjects (see below).
However if absolutely necessary one can add tex commands to the files webwork2/conf/snippets/hardcopyPreamble.tex which is loaded before printing a hardcopy and to webwork2/lib/WeBWorK/Constants.pm which is loaded before each equation is typeset. In order to maintain compatibility of p[roblems over a period of time one should be pretty cautious about doing this.
For the math objects make sure to load the macro file "Parser.pl"
and try something like this snippet:
($a,$b,$c,$d) = (23, 25, 45,8);
$ma = Matrix([$a, $b], [$c, $d]);