Hugo has moved to Goldmark as default Markdown processor.
And as per today Goldmark supports adding classes, id and custom attributes to heading only. With more to come in future.
## heading ## {#id .className attrName=attrValue class="class1 class2"}
## heading {#id .className attrName=attrValue class="class1 class2"}
You can read about goldmark custom attribute support on their github readme.