Once you’ve reached either of the points I’ve already noted, your next trip to the Shrine of Talos in Markarth will have a very different and most unwelcome result- when you arrive, three guards are pacing the room, and Eltrys is lying dead at the foot of the Talos statue. Once you approach close enough to really be considered in the shrine, the central guard will step forwards and tell you to halt- he’s placing you under arrest for murder, and for conspiracy against the city of Markarth. When you protest, he complains about all the work you’re causing him- people who need to be killed, witnesses that need to be fabricated, and so on. You, it turns out, are being blamed for every one of the murders that has occurred during your investigation into the Forsworn conspiracy- right on up to Margret’s, if she’s dead.
You have two choices here- you can accept blame and go to Cidhna Mine (where Madanach can be found), or you can refuse to be taken alive. The former option moves you on quickly, but the latter provides you with an unique opportunity. When you refuse to be arrested, the three guards here attack. As you fight them, one or two more guards will arrive from the city outside and join in the fight. Once these are all dead, you can actually leave into Markarth.
As soon as a guard spots you, they will run up and attempt to arrest you- if you claim to have been framed, the guard will argue that you’ve been seen getting up to some shady stuff and there are a number of witnesses, so that’s not going to work. You can again accept to go to Cidhna, or refuse to be taken alive. This will repeat every time you encounter a new Markarth guard, allowing you to fight and kill every single guard in Markarth without any bounty or standing repurcussions, since you’re to be sent to Cidhna Mine for life anyways. That also will let you loot all of the guards, some of whom have keys to the Dwemer museum in the Understone Keep. Two of the guards- the ones outside the front door to Understone Keep- will respawn every time you enter the city, so you both will always have a chance to get arrested and sent to Cidhna Mine, and will always have more guards to fight.
If you have a follower and a skill you’ve just made Legendary that can be applied here- mostly combat skills, though if you have no follower, you can hide out somewhere guards can’t find you and snipe them via archery or magic to improve your sneak skill- then this can be a good opportunity to work whatever skill’s level up again with relatively low risk- the Markarth guards only follow you up to a certain distance from the city, and they don’t have much in the way of especially dangerous skills or attacks.