It is possible, but you'll have to get bloody. I tried the 'you'll never take me alive!' method at first but I was too weak to handle three guards at once in honourable combat back then. Thus after a few reloads I just sneaked into the shrine and started firing arrows as soon as I walked in. Either way, despatching all of the guards seems to remove all witnesses so there's no-one left to chuck you in the mines and no bounty on your head either. After that the quest completed normally in my journal (and thus reassured me I wasn't cheating the system a little bit!)
Well, I've fled Markath (glorious action, I tell you - riding out into the night on my horse, past arrow-shooting guards, until I was out of the reach. Just when I had passed the last guards near Markath, I ran into a Forsworn hideout and just then a dragon come swooping in, too. That was an epic fight, I tell you - everyone against everyone else
).
No, my problem is that I can't return to Markath. And I don't really WANT to slaughter all the guards. I'm on their side, well, in a way...