Assuming your question is about naming dynamic columns in PIVOT query, answers in these threads may help.
I didn't test it myself, but the mssql-jdbc seems to support such a statement, so it should work with MyBatis as well.
Mapping to a map (e.g. HashMap) should be pretty straightforward.
Mapping to a custom object is possible, but might be difficult if the number of returned columns is unknown.
If you have any difficulty, please create a minimal repro project and share it on your GitHub repo.
I will take a look when I have time.
Here are some project templates and examples.