The software solution to fixing a broken iPhone lock button
If any buttons on your iOS device stop working, there is a little known trick we can show you that may help!
Go to Settings > General > Accessibility > Scroll down to click Assistive Touch and slide the toggle to turn ON.
A grey square with a white circle inside will appear floating on your screen and you can drag this square anywhere on your screen.
Pressing this icon will bring up a menu with four different options to choose from: Siri or Voice Control, Device, Home and Favourites.
To access the lock button, tap device, and then tap Lock Screen.