This is not always possible. For example, there is a multiplication-compatible
partial order $<$ on $M$ such that $aa < ab$ and $bb < ba$. In any
multiplication-compatible extension of this order, $a$ and $b$ must be
unrelated, so this order cannot be extended to a total order.
It's not totally obvious that there is such a partial order. The relation
generated by the two inequalities $aa < ab$ and $bb < ba$, as well as the
requirements of transitivity and compatibility with multiplication is
"$w < w'$ if $w$ can be transformed to $w'$ in at least one step using the
string rewriting rules $aa \to ab$ and $bb \to ba$".
To verify that this is actually a strict partial order, we need to check
it's irreflexive, which amounts to showing that the string rewriting system
always terminates (since the length is never increased).
One way to see this is to observe that once you've applied the rule to the
first two characters of any string, they will remain different from that point
forward. So, given some string of length $n$, any sequence of rewrites
is eventually a sequence of rewrites of just the tail of the string. By
induction on $n$, that sequence must terminate, so we are done. QED.
Addressing "Does such a linear order even exist?":
Yes, there are many. As J.E. Pin says, the
shortlex order is one.
You can also mix and match in all sorts of ways. Here's one broad way to do
that, which I'm sure can be generalised further.
Given a finite family of functions $f_i: M \to X_i$ from $M$ to totally ordered
sets $X_i$, with the properties
- if $f_i(x) < f_i(y)$ then $f_i(zx) < f_i(zy)$ and $f_i(xz) < f_i(yz)$
- if $f_i(x) = f_i(y)$ then $f_i(zx) = f_i(zy)$ and $f_i(xz) = f_i(yz)$
- the function $w \mapsto (f_1(w), \dotsc, f_n(w))$ is injective
then the ordering induced on $M$ from $X_1 \times \dotsc \times X_n$ (with the
lexicographic order) is a multiplication-compatible total order.
Some example of such functions $f_i(w)$ are "count the number of $a$s in $w$",
"take the length of $w$", "subtract the number of $a$s in $w$ from twice the
number of $b$s in $w$".