According to Canon Law:
Canon 751 † Heresy is the obstinate denial or obstinate doubt after the reception of baptism of some truth which is to be believed by divine and Catholic faith.
Code of Canon Law: New English Translation. (1998). (p. 247). Washington, DC: Canon Law Society of America.
The Church's teaching on the death penalty is not a matter of divine and catholic faith, that is, something divinely revealed.
Therefore to oppose it is not technically heresy. However, the canon after this says,
|Canon 752 Although not an assent of faith, a religious submission of the intellect and will must be given to a doctrine which the Supreme Pontiff or the college of bishops declares concerning faith or morals when they exercise the authentic magisterium, even if they do not intend to proclaim it by definitive act; therefore, the Christian faithful are to take care to avoid those things which do not agree with it.
The teaching on the death penalty would fall under this canon.