Anything CAN work if you make it work. Unless you have thousands of fans, you won't have to worry too much about causing an uproar, so tell the story you want to tell.
It can easily be done badly, but all that means is you're losing readers because you're not writing a good story, NOT because you killed your MC.
As far as execution goes, make sure you properly build up whoever their replacement is. Erik Larsen successfully killed off his character, Savage Dragon, replacing him with his son, Malcolm. Readers grew up with the boy, so by the time he took over, he was an established mainstay.
Also avoid killing them off in a really dumb way. Make sure the death has weight and makes sense to the plot. If you're MC wins all the time, they shouldn't just suddenly lose and die out of nowhere. Explain it.
And lastly, try not to be cliché. Your MC sacrificing them self for someone else is kinda played out... I mean, you can still do it if your find a way to do it that hasn't been done before, but try and make sure we can't see it coming, otherwise it could turn your story into an eye roller.