For a method of execution to be painless, steps have to be taken to ensure that the brain is incapable of processing pain signals at any stage in the process.
In practical terms, there are two ways this could be achieved: A) By the painless administration of anaesthesia prior to execution; or B) By destroying the brain faster than nervous impulses can propagate.
Class 'A' killings include lethal injections, gas chambers etc; Once anaesthesia is achieved, any means of killing is equally painless, so it is irrelevant how the
coup de grace is achieved.
Class 'B' killings require rapid physical destruction of the brain; Captive bolt guns, firing squads with the head as the aim-point, or the use of high explosives would achieve this, if properly managed; However these techniques may be very messy.
Most execution methods fall into neither category, and almost certainly cause pain to the executee - hanging, beheading (including guillotining), firing squad with the chest/heart as the aim-point, etc. fall into this category.
There is good evidence from the French Revolution that beheading does not cause instant (or even very rapid) loss of consciousness; it seems implausible that this method of execution is painless.
Of course, none of this answers (or even addresses) the two most important questions: Should executions be used at all? and If we do use them, should we care about whether they are painful?
These are not merely moral questions; in the USA, for example, the eighth amendment provides that 'cruel and unusual' punishments are forbidden, which I believe should rule out executions that cause pain (on the basis that this is cruel), and should also rule out executions altogether in the 21st century (on the basis that this punishment is no longer usual).
Even if we only look at capital crimes, and only in those States which have the highest rates of execution, it is hard to argue that this punishment is 'usual'; most convicts who are found guilty of capital crimes are not executed. According to
the BJS, roughly 0.06 people are convicted of murder per 1000 population per annum; that's about 18,000 convictions per annum. In the decade to 2014, 51 executions have been performed (
source); making the punishment of execution applicable to 0.28% of murder convicts. If a punishment that is not applied for the other (at least) 99.72% of people convicted of murder doesn't count as unusual, then what does?
The death penalty is expensive, usually inhumane, often cruel, certainly unusual (and as a result probably unconstitutional), and is ineffective as a deterrent. It is no more effective at preventing re-offending than life without parole - particularly given that a death sentence implies a long custodial term prior to execution being carried out; and it is impossible to make any attempt at restitution or compensation for any person who is subsequently exonerated. It should be discontinued.