Create a new config variable $wgSectionFragmentFlavor that can be an array, e.g. [ "legacy", "html5" ]. Have Parser::formatHeadings() output a section ID tag for each type listed in the config variable. For example, if it's set to "legacy", it should output:
<span class="mw-headline" id=".D0.9B.D0.B8.D1.87.D0.BD.D1.8B.D0.B9_.D0.B7.D0.B0.D1.87.D0.B5.D1.82">Личный зачет</span>
If it's set to "html5", it should output (with no whitespace in the id):
<span class="mw-headline" id="Личный_зачет">Личный зачет</span>
If $wgSectionFragmentFlavor includes both types, it should output:
<span class="mw-headline" id="Личный_зачет">Личный зачет</span><span class="mw-headline" id=".D0.9B.D0.B8.D1.87.D0.BD.D1.8B.D0.B9_.D0.B7.D0.B0.D1.87.D0.B5.D1.82"></span>