One Sparrow is correct, the death penalty is only licit in cases where there is no other way to effectively protect society as a whole to a reasonable degree (CCC 2267 and Evangelium Vitae).
The mental capacity of the criminal doesn’t really enter into that equation, but it does help highlight why the Church teaches that, in the US, where some states do execute the mentally infirm, the practice feeds into an overall culture of death (see the United States Catholic Catechism for Adults, Chapter 29).
Pax Christi