It already does. The problem is that both your shortcode and the icon file contain newlines, and per the CommonMark spec the heading element ends at the first newline. Try it yourself:
In the above we remove newlines from the SVG file with strings.Replace, and we remove whitespace from the shortcode itself using the {{- and -}} action delimiters.
Step 2: Configure goldmark to treat HTML in Markdown as safe
In your site config:
[markup.goldmark.renderer]
unsafe = true
The configuration above is safe if you control the content.
Example
git clone --single-branch -b hugo-forum-topic-55399 https://github.com/jmooring/hugo-testing hugo-forum-topic-55399
cd hugo-forum-topic-55399
hugo server
Wow, thank you very much for your clear explanation. I was genuinely surprised to learn that the problem was just caused by a missing line break, and I didn’t expect it would turn into you helping me debug my setup. Truly appreciate your help and generosity.