You can do this using a command-sequence that inserts the macro followed by various key-presses. The straightforward way:
command-sequence math-insert \Mthree{}{}{}{}{}{}{}{}{}; repeat 9 char-left
inserts your macro followed by 9 left key presses. The more flexible version:
command-sequence math-insert \Mthree{}{}{}{}{}{}{}{}{}; char-left-select; char-right
should end in the first argument position no matter the number of arguments to your macro, abusing the fact that char-left-select (=Shift-left) selects the whole macro hence placing the cursor in front of it.
Note the {}:
For custom macros with at least one argument,
math-insert \foo
will absorb a possible selection as its first argument and any following symbols as further arguments. If there is no selection, it will absorb following symbols as arguments. On the other hand:
math-insert \foo{}{}
(in case of two arguments) will replace a possible selection, deleting it, but in turn not absorb following symbols.
None of the two options are ideal, but I prefer the second, so I added the {}.
For LyX-native commands like \root or \sqrt that take at least one argument,
math-insert \root
will take possibly selected elements as its first argument, but not absorb following symbols. It will also automatically place the cursor in the first argument, as you want for your macro.
I have not been able to completely recreate the native behaviour using command sequences. This:
command-sequence cut; math-insert \foo{}{}; repeat 2 char-left; paste
will take a selection into the first argument, and will not be executed when there is no selection. However you will lose the clipboard contents.
I have tried combining both versions using command-alternatives, but using command-sequence after command-alternatives does not seem to work.
A possible workaround would be to create two separate shortcuts for selection or no selection.
Alternative without macro
A better alternative might be to use a shortcut that enters the whole construct directly without using a macro. In your example, there are LyX commands for that:
math-matrix 3 3
for an array, or
math-ams-matrix 3 3 pmatrix
if you want a pmatrix or similar.
This avoids the issues with the arguments I described above and also makes your source code more compatible when transferred to other users or documents.
For other constructs that don't have dedicated LyX commands, you can again use command sequences. In your example, you can manually build the above like this:
command-sequence math-insert \array; repeat 2 tabular-feature append-row; repeat 2 tabular-feature append-column
or even:
command-sequence math-insert \begin{array}{ccc} \\ \\ \\ \end{array}; up
In the same way as pressing right when the cursor is left of a 3x3 array, after the math-insert part, the cursor ends up in the first field of the second row, so "up" places it in the first field of the first row.