MathJax can handle math macros if they rely on things that MathJax can do. My example from the post works with MathJax, for example. You need to enter math mode somewhere on the page and then define the macro. Like if you do this:
Then later on the page you can do this:
I found a place in the code where you can add macros for image mode. There is a note there that says "stay tuned" and this will work for MathJax too. I suspect that note is like 10 years old.
You can separately add stuff to a hardcopy header for hardcopies. But it doesn't appear to recycle what you may have done for image mode.
PreTeXt makes WW problems for a math textbook, which may have its own custom LaTeX macros. So far we have gotten away with redefining the macro right before you use it. Like
MathJax does not object to redefining it this way when it has already bee defined. Images mode is atomic, so no objections there either. Hardcopy is fine because you see the scoping braces around it all stops LaTeX from seeing it as being redefined.
But this is not the same as just cerntalizing the definitions. Overall, it looks like this would have to be a new feature.