Headings can't take other formatting modes, see https://www.dokuwiki.org/faq:headerlinks . Presumably this also affects the var plugin because it performs text substitution.
If you have PHP enabled via the phpwikify plugin, you could emit the pagename yourself:
<phpwikify>
global $ID;
echo '====== ' . $ID. '======'; // or some other way to get the pagename
</phpwikify>
But note this is wasteful. Another option would be to use a plugin that extends headings, but note that the plugins might generate invalid headings and in general invalid HTML as a result.