To do this, the assistive touch feature needs to be enabled. To enable this, go to Settings > General > Accessibility > Assistive Touch. Turn it on from there. This will bring up a little square button that can be moved around on the screen. This comes up on the power off screen.
To take the screenshot, press the assistive touch button, choose Device, More and then Screenshot. This will allow to take a screenshot of the power off screen as well as any other screens where the normal screenshot feature may not be available.