An operator can force unlock elements, so they are free to be changed. But AFAIK there is no restore that puts back the lock. Might be worth an investigation...
q.
P.S. You could write a script to save all t_object.style values which contain "Locked", do the unlock/change and then restore the style.