How to use mhchem in wordpress?

The Mathjax plugin provides a filter named mathjax_config that can be used to add config parameters, something similar to this should do the trick:

add_filter( 'mathjax_config', function() {
    return ['Tex' => [ 'extensions'=> [ 'path/to/mchem.js'] ] ];
});

In the event you’d like to remove dependency on the plugin, you’ll need to enqueue the mathjax library, whitelist all the relevant tags so they aren’t