Vernon Madison v. Alabama
In the Vernon Madison v. Alabama case the Supreme Court of the US ruled that executing someone who cannot understand the reason for their execution violates the ratio legis of the 8th Amendment to the US Constitution's ban on "cruel and unusual punishment".
A federal appeals court found that Mr. Madison, who was scheduled for execution in 2016, was incompetent to be executed because he had no rational understanding of the crime for which he was convicted.
The legal question, then on whether someone who can't remember committing a crime is nonetheless capable of "understanding the reason" for their execution is more constricted than the more philosophical and general question which is can someone who can't remember performing a given act be genuinely morally responsible for that act?
Locke argued that if you can't remember performing a given act, then you are literally not the same person as the person who performed that act.
So according to Locke, Madison is not, now, morally responsible for the murder, since he is not even the same person as the murderer, and hence does not deserve to be punished for it.
Though the Supreme Court doesn't go so far as Locke I think the philosophical argument still packs a decent punch and can be used in the court of law by criminal defense lawyers.