These patches are based off Mastodon v2.7.1. They will probably need some work to apply to future releases.
mathjax.diff adds MathJax to render LaTeX. You need a copy of MathJax under the URL /MathJax.
Write inline maths between \( and \), and display-mode maths between \[ and \].
autolatex.diff adds automatic replacement of some LaTeX with unicode equivalents in the toot compose box. It only applies to text not within LaTeX delimiters, so doesn't interfere with MathJax.