That is something you’d be force to decide on a case by case basis as a judge. The death penalty is not like abortion - i.e. intrinsically evil, so there is room for prudential judgements made by those, like judges, in authority.
The full entry in paragraph 2267, cited in part by Tim above, of the CCC reads:
2267 Assuming that the guilty party’s identity and responsibility have been fully determined, the traditional teaching of the Church does not exclude recourse to the death penalty, if this is the only possible way of effectively defending human lives against the unjust aggressor.
If, however, non-lethal means are sufficient to defend and protect people’s safety from the aggressor, authority will limit itself to such means, as these are more in keeping with the concrete conditions of the common good and more in conformity to the dignity of the human person.
Today, in fact, as a consequence of the possibilities which the state has for effectively preventing crime, by rendering one who has committed an offense incapable of doing harm - without definitely taking away from him the possibility of redeeming himself - the cases in which the execution of the offender is an absolute necessity "are very rare, if not practically nonexistent."68
The CCC references Pope John Paul 2’s Evangelium Vitae paragraph 56, which reads:
This is the context in which to place the problem of the death penalty. On this matter there is a growing tendency, both in the Church and in civil society, to demand that it be applied in a very limited way or even that it be abolished completely. The problem must be viewed in the context of a system of penal justice ever more in line with human dignity and thus, in the end, with God’s plan for man and society. The primary purpose of the punishment which society inflicts is “to redress the disorder caused by the offence”.46 Public authority must redress the violation of personal and social rights by imposing on the offender an adequate punishment for the crime, as a condition for the offender to regain the exercise of his or her freedom. In this way authority also fulfils the purpose of defending public order and ensuring people’s safety, while at the same time offering the offender an incentive and help to change his or her behaviour and be rehabilitated. 47
It is clear that, for these purposes to be achieved, the nature and extent of the punishment must be carefully evaluated and decided upon, and ought not go to the extreme of executing the offender** except in cases of absolute necessity**: in other words, when it would not be possible otherwise to defend society. Today however, as a result of steady improvements in the organization of the penal system, such cases are very rare, if not practically non-existent.
In any event, the principle set forth in the new Catechism of the Catholic Church remains valid: “If bloodless means are sufficient to defend human lives against an aggressor and to protect public order and the safety of persons, public authority must limit itself to such means, because they better correspond to the concrete conditions of the common good and are more in conformity to the dignity of the human person”