You can reset an iPhone, even without the password, by putting it into "recovery mode" or erasing it via iCloud's Find My ...
To sign out of iCloud on all of your devices at once, you can head to iCloud's website and change your password.