I dunno. I can kind of see how releasing the Markarth equivalent of Usama Bin Laden from their very own Guantanamo Bay might just make you unwelcome there. Just saying. I didn't think of this as being any different than how in the Fallout games you can get yourself permanently banned from certain locations if you piss people off badly enough. I thought "Cool, I'm f***ing public enemy #1." and enjoyed the idea that our choices have real consequences. I was actually really disappointed to find out this was a bug.
But whatever. Whenever I go into Markarth, I just cut through guards until there aren't anymore. Problem solved.
I let their king go and didn't receive any bounty. The trick is not to join the Forsworn in the rampage. Stay hidden or, simply, go back to the ruins once the battle starts and wait for a few hours. When you go back, climb to the Jarl palace to get your parole. He will recognize that you're not responsible for the crimes happened in Markath (although he will not acknowledge the corruption of his brother and, if he still lives after the battle, he will be back to his usual dirty business).
People and guards in town will still comment how they saw you escaping with the Forsworn commenting that "several people died also because of you". The three guards at the temple of Talos will keep on respawning: this is a known bug; simply avoid that area or, if you must enter use the "kill all" console commands before they see you. Otherwise you'll get a bounty again. The guard threatening you outside the inn will also respawn even if killed or disabled via the console: this is another bug that waits to be fixed. Other than that, business is as usual in Markath. A shame all the Forsworn will remain hostile save for those in a cave. Bug or intentional?