drewwalton19216801 is correct. It is illegal. To answer your question, NO you do not have to root the phone in order to change it's ESN. Rooting your phone allows you to adminster your phone better and unlock features you normally wouldn't be able to. Messing with the phone's NV items (the radio, not the system) is not recommended, you can brick the phone.
You can have it flashed... (MetroPCS and Cricket are examples of companies that add the phone's ESN to their database and allow it's usage in their network.)