In conf.py of your Sphinx project, add the extension with:
conf.py
extensions = ['sphinxcontrib.katex']
For enable server side pre-rendering add in addition (nodejs installation needed):
katex_prerender = True
See the Configuration section for all available settings.