As it happens, I was talking to a friend who IS a lawyer about this just last week! Of course, she’s a US attorney, not UK, so I’m not sure about the nuances of these things and how they vary from nation to nation. But she seemed pretty clear that in a situation like that, at least in the US, Sherlock would probably be found guilty of murder.
The thing is that although CAM was blackmailing Mary with a threat to her life, it was not a clear and present threat to her life. Nobody was in immediate danger from CAM at the moment when Sherlock pulled out a gun and shot him.
(Also worth noting is that if the case had gone to trial, if Sherlock had wanted to get his charges trimmed down even to manslaughter—it would be voluntary manslaughter, effectively murder with provocation—he would have needed to reveal the chain of threats and events, which would have meant revealing Mary.)
(Also also worth noting is that, at least in the real world, the additional question would almost inevitably come up of why John had a gun, and why it was in his pocket when he came to visit the skeevy rich white dude who was blackmailing his wife.)
But regardless of whether it was manslaughter or murder, Sherlock would most likely have gone to prison for years. Upon his release, assuming he didn’t get himself knifed or something in the meantime by one of the many inmates who undoubtedly have reason to hate his guts, he would have had a permanent record as a felon. His ability to do the job he had chosen—the work that enables him to maintain a functional place in society rather than potentially destroying himself or others—would have been permanently disrupted. No police officer would ever be able to let him work on one of their cases again, as his involvement would almost certainly lead to their case being thrown out of court.
And have you ever read what long-term solitary confinement does to human beings? It is not merciful. It is incredibly destructive to the psyche, and effectively a form of torture. It is not, by any compassionate standard, an acceptable alternative (and the fact that we sometimes do it in the US anyway is a cause for righteous outrage).
Instead of any of that, Mycroft scooped Sherlock out of the situation and put him on a path where, despite having blown away a rich, powerful, well-connected old white dude in front of the police (granted most influential citizens of the EU probably set up and cheered when they heard the news), he came away with no criminal record at all. Which, really, is pretty ethically wonky in its own right, but that is both Mycroft and the intelligence service for you.
And Mycroft sent him off on a mission that might get Sherlock killed in about six months, assuming that he or Mycroft couldn’t come up with something by then.
As it turns out, Mycroft did—about four minutes later. Which kind of goes to show that he was really just waiting for an excuse.
(Tangential to this, I wonder what sort of shop MI6 is running in Moftiss’ England, where they apparently keep trying to court a civilian to take lethal government intelligence missions to sensitive locales like Eastern Europe. Granted Mycroft’s been trying to talk him into coming to work for the Crown for years, though he didn’t originally want Sherlock to take this one; maybe he sold the idea to his colleagues too well?)