If the iPhone is a trusted device on your Mac or PC, it’s possible iTunes could work to back up. Then you can restore the backup to another iPhone. This is a big maybe as it all depends if iTunes will ask you to enter a passcode on the phone. If you’ve never connected that iPhone to your computer before, it’s not going to work. You need a display.
However if you don’t know the password to the iPhone and / or the iCloud account, it’s not going to work assuming it’s a hand me down phone and not originally your phone.