The death penalty doesn't work as a deterrent, whether executed publicly or behind closed doors because murders are either planned and in that case the murderer to be plans it so they hopefully won't get caught or the murder happens in the heat of the moment, in which case the perpetrator is so far gone into the red zone in that particular moment that they're incapable of thinking about the consequneces. Plus death row inmates cost a lot more than regular prisoners, due to special housing and lots of appeals.
The only way this would work cost efficiently is, if you were to go the Chinese way, which is trial, conviction and then execution immediately afterwards, but that's not how it works in the western world.