Can you flash an iPhone that has a bad ESN?

I just got an iPhone 4 from a friend and it has a bad esn with sprint. It's CDMA. Can I buy a kit an flash it to straight talk or net10? I know it can be done but can it be done even tho it has a bad esn?

Net10 and Straight Talk both forbid iPhones from CDMA carriers (Sprint and Verizon), on top of the fact that the bad ESN will preclude it from service in the USA ever again.