Yes, you can recover your iPhone data when the iOS device screen is locked. However, the primary condition is that your computer should be trusted by the iPhone.

If the device is not trusted, you can recover lost/deleted files from either the iTunes backup or iCloud backup module of Stellar Data Recovery for iPhone.

The software can also recover lost data, if your iPhone touchscreen or display is not working.