How to reset my iphone?

So i'm selling my old iphone 5 to a friend but i can't sign out of apple id as i have forgotten the password does putting it into recovery mode work?

Go to settings then general and then select Erase All Content and Settings. After typing in your passcode if you've set one, you'll get a warning box appear, with the option to Erase iPhone in red. Tap it

Sledgehammer and Apple Care.

No, recovery mode will not change anything.
It will always go back to the Apply account info during reset / activation until you sign in and disable it.

It's the basic anti-theft system and there's no way around it but find you password.
(The ID is stored on Apple's servers and not the phone itself - the phone checks in occasionally to see if it is linked to a person / account. Nothing you can do to a phone changes that).

You can recover your password through the Apple web site, here:
https://support.apple.com/...b/HT201487