The short answer is that you need the password for the old Apple ID, then you can remove it. Detailed instructions from MacWorld:
"This is a security measure to prevent stolen phones from being sold on.
If you know the person, then you'll need to get their password from them (or get them to enter it). If you don't have their password (because you bought the phone second-hand) then you should get in touch with the person as soon as possible, or return the iPhone for a refund.
Once you have the password, follow these steps to remove the Apple ID account from iCloud and Find My Friends:
1. Tap Settings > iCloud.
2. Scroll down and tap Sign Out.
3. Tap Delete from My iPhone.
4. Enter the password of the person's Apple ID.
5. Tap Turn Off.
When signed out you can tap Sign In and enter your Apple ID and password to start using the device.
How to get someone else's Apple ID off your iPhone: What if I don't know the password?
Unfortunately, we don't know of a way to remove an Apple ID from an Apple device if you do not know the password. This is a security measure put in place by Apple to help combat the theft of iPhones.