Use assistive touch if you need to shut off your iPhone by going to Settings > General > Accessibility > Assistive Touch. An icon with a dark square and white circle will appear on your screen
Tap the icon to open the Assistive Touch menu, and tap Device > Lock screen.  Hold the Lock screen icon to shut your iPhone off.