Well my country doesn't execute either murderers or the mentally ill

..theoretically it could execute a traitor, I believe...
For me Gandalf's words, were a factor in shaping my opinions on the death penalty, but given that ME is a world where capital punishment exists I will leave that to one side.
Gollum was tortured in Mordor - if he wsa "relatively unharmed" it was because he was so damaged already ...
You cannot punish people for things that they might do - well the state can't (to no doubt misquote PJ O'Rourke in "Parliament of Whores", "the supreme court can not punish you for having a smart look on your face - which is the difference betwen having a judicial system and having a mother").
Gollum was after the Ring for himself so to that extent, I don't think he was consciously on an errrand for Sauron or his servant .
Gollum's "treachery" if such it was, was essential to the destruction of Sauron.
So I disgree with you other than that I do think, but from a very different perspective, that Gollum deserved his death - as a release from the terrible burden of his life and reunited with his Preciousssss