A Windows Phone device can be erased although the screen is locked.
When the user is prompted to do a factory reset, they should reset the device using the button combination (please refer to manufacturer documentation for more info).
The factory reset removes the screen lock.