I also tried on a SAP account that doesn't have an account definition and it works in that case.
So I would like to ask you if there is a method to lock / unlock without removing the account definition.
Yes, it's not working for the entities that are connected to a person via an account definition.
In particular I verified also that if you revoke the account definition, the SAP account remains linked to the identity (so the account def is removed), and then you can lock and unlock the SAP account.
Instead if you click on assign account def in the Overview | Task of an employee, then select remove account def, at the end of the processes the identity it's not linked with the SAP account. Are there differences between revoke and remove account definition?