This can be fixed on PC by waiting for a guard to confront you, then opening the console and selecting the guard by clicking on them. With the guard selected type paycrimegold into the console. You will be transported to a random location in Markarth with your bounty erased. Simply yield the guards by unsheathing and sheathing your weapon and the guards will return to normal patrol.