This is how I want it to look like in Visual Studio Code, but this is how it turns out in obsidian. The code block appears as a string instead of code block.
This is not a direct answer to your question because I don’t know the limitations in working with markdown syntax inside html… I just know, by experience, that md syntax works inside a <span> tag.
But this is a suggestion: why not working with “Fold heading” or “Fold indent”? (Settings > Editor). With this you don’t need any html code, just .md syntax.