I try to reformulate and simplify the question.
Example:
A <span class="myStyle">word</span> with a custom style.
Convert it from markdown to HTML (pandoc -f markdown -t html) and you get:
<p>A <span class="myStyle">word</span> with a custom style.</p>
Convert it from markdown to ICML (pandoc -f markdown -t icml) and you get:
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
<Content>A </Content>
</CharacterStyleRange>
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
<Content>word</Content>
</CharacterStyleRange>
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
<Content> with a custom style.</Content>
</CharacterStyleRange><Br />
</ParagraphStyleRange>
The styled word is put in a CharacterStyleRange of its own, but there's no trace of the class attribute.
Is there a way to get this:
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
<Content>A </Content>
</CharacterStyleRange>
<CharacterStyleRange AppliedCharacterStyle="$ID/myStyle">
<Content>word</Content>
</CharacterStyleRange>
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
<Content> with a custom style.</Content>
</CharacterStyleRange><Br />
</ParagraphStyleRange>
This way, when you import the ICML in InDesign, in a document with myStyle previously defined as a character style, you get the right formatting.
The same could be thought for DOCX and ODT, with reference documents that contain the styles you need.
I have used the class attribute to map the style, but another attribute could be used: it's only conventional.
I think this "style mapping" should be disabled by default, but enabled by a command line option.