Don’t worry when power button in your iPhone does not work, you can use assistive touch feature lock your iPhone. Listed below are the steps to enable Assistive touch on your iPhone.
Step 1: Tap Settings icon on your iPhone screen
Step 2: In the Settings screen, tap General Settings.
Step 3: Then tap Accessibility option under General Settings. This should display the following Accessibility options.
Step 4: Scroll down to Interaction section and tap on Assistive Touch and Turn on the feature. Now you should notice Assistive Touch option on your screen as shown in the below screen shot.
Step 5: Now lock your iPhone, tap Assistive Touch then device option and select Lock Screen.
Assistive Touch also provides to option to access Notification Center, Siri, Home Screen, Control Center, Rotate Screen, Volume Controls. Screenshot etc.