Pre-Revolution, no.
Capitalism corrupts everything and every death penalty sentence carried out likely carries the stains of greed, imperialism, and corporate interests. False convictions are rampant and always target minorities. Under Capitalism it can only act as a tool for genocide.
During a Revolution, yes.
Revolutionaries rarely have the resources to hold large numbers of POWs in prisons, so the worst of them should be executed (neo-nazis/nazis, high level war criminals, etc). Those are completely irredeemable in those circumstances anyway.
For other "normal" POWs I support a strategy used by Mao against the Nationalists. He had POWs go through a course, like a school course, about Marxism, with assignments, quizzes and tests, etc., and afterwards the graduates would receive an actual diploma stating they have successfully completed the course and were allowed to either join the revolutionaries, go home peacefully, or even go back to the Nationalist armies.
Those that went back to the Nationalist armies were seen as too compromised by the Nationalist armies and either sent home anyway, or in most cases outright imprisoned and sometimes executed. So many did not rejoin their previous commands for obvious reasons.
So under such a strategy, you can't lose.
After a Revolution, no.
No need. Not even for those who are irredeemable, such as someone who performs heinous crimes or what not. Life sentences should suffice for those who shouldn't return to society at large. Those in prison should have access to education, personal fulfillment, and work for fair pay which they can send to their families, have personalized experiences in prison (within reason, obviously everything should comply with safety standards of the convict, but what is the harm in allowing a convict to have a potted tomato plant or whatever if they aren't going to misuse it?), etc. Solitary confinement and other methods of prison torture should go away completely, with other safety methods researched and utilized to ensure safety regarding the very very very very rare individual who is unsafe to interact with anyone and everyone (after all, even some 35 year old who spent the last 5 years murdering 20 children managed to go the first 30 years without doing so, right?).
Most of those who have committed the most heinous of crimes will likely have some form of mental illness at the root of it. Trauma could be likely, or forms of delusion or other mechanisms. Therapy and thorough documenting of their cases could not only help the individual recover, but may lead to new therapeutic techniques or lead to better establishing the root causes of such issues which may in turn assist therapists in wider society treat those who are at risk of this type of behavior before they start such behavior, or otherwise help policymakers establish policies which are more inclusive to prevent others from acquiring the traumas which may have triggered the thoughts in the inmate which led to their conviction.
Not to mention that even under ideal communism, the criminal justice system will still be limited by human capacity. Even if the process is somehow 100% automated or performed by AI, that too will be limited by the biases and other human limitations of the automation engineer or Machine Learning/AI programmer and the likely human created/gathered data it is fed. There is a non-zero percent chance of a false conviction, so that means there would be a non-zero percent chance of a wrongful murder at the hands of the state during the execution of a death penalty.
Also, after the revolution, as poverty decreases so will crime. A prison system which is not privatized and which operates under a government driven to eradicating poverty and establishing a society built on true egalitarian principles will have far far fewer prisoners and fewer crimes. Why risk altercations with individuals and law enforcement by spending hours pickpocketing in subways for such few gains when you can spend that same amount of time pursuing free education or a job doing something fulfilling which will pay much more and provide much more satisfaction? Need a rush of adrenaline? Become a skydiving instructor or rock climbing guide. Prison space will invariably open up and the resources necessary to support the few left over whose crimes are not related to poverty will certainly be there.