Check if the IMEI is blacklisted first. If that's the case, it's usually because of a unpaid balance or the phone was stolen. Either way the IMEI is “branded” for good. To avoid wasting time, check the status of the IMEI on Swappa. Since we now have global blacklists the phone is useless everywhere; even for international use.
If the IMEI is bad because it's actually stolen, take the phone to the police and see if you can get it legally by giving the owner a chance to reclaim it. This isn't always possible but most states allow for this. It usually means the police hold the phone, so be prepared for that. If it is clean, try to restore the phone in recovery mode to fix the baseband firmware: OBSOLETE - *Pre iPhone 7/7th Gen Touch* How to access Recovery Mode
If it's stolen and you get it keep it this way do not expect the carrier to help you make it usable as a phone, it's just dead. Even if you can fix the IMEI by replacing it, it is legally sketchy. Possession of a blocked phone for nonpayment is fair game, but legally EVEN IF YOU HAVE PHYSICAL POSSESSION OF THE PHONE WITH THE NEW IMEI# IT IS CONSIDERED PHONE CLONING. It can even be hard to defend even with physical possession of the device you ripped the IMEI# from. If I was going to do it, I'd rip the number off of the phone, then destroy the old board. If there was no uncorrectable parts pairing, I'd just swap boards!!!
If recovery mode doesn't fix the phone, it's a hardware baseband problem. The motherboard will need to be replaced since the baseband is typically paired. The boards usually cost as much a whole phone so it may not be worth it to replace the board. That said, if you do swap the board you should try and check the IMEI if you can do so. I’d also STRONGLY RECOMMEND getting the matching back so the phone and board have the same identity, to avoid problems in the future. It typically doesn’t matter but if a carrier or secondhand buyer sees it, it doesn’t always come off well. I’m not bothered by it to the extent I will run away from the phone, but it is a red flag that something is up in most cases. I’m going to check the IMEI per the board anyway, so it’s kind of moot but I like to see matching identities.