Gotham is a municipality, so the question is actually about the death penalty in Gotham City's real or fictional state in the USA.
If there is a definite canonical real state for Gotham City we can discuss the non execution of Batman's rouge gallery in connection with the criminal laws of that state. If it is definite and canonical that Gotham is in a fictional state, someone might try to deduce whether that state has the death penalty.
Of course there is strong logic and reason to believe that all fiction and superhero comics in particular happen in alternate universes and not in our universe. Thus many comics fans might prefer to deduce the Batman laws only from evidence in the comics (such as super villains not being executed), not from real life.
Since Batman super villains get sent to Arkham Asylum they should be judged legally insane and maybe there is a law against executing legally insane persons.