In the US divorce is a matter for state law, but generally it is possible to divorce in the US if your spouse lives at a US address at the time the divorce is filed. It is often possible to divorce in the US even if your spouse has moved overseas, though some states may restrict this to uncontested divorces. If your marriage certificate is not in English you may need to have a certified translation made to file with the petition. Your home country may require you to register the divorce with them once it is done, though this is a matter for your home country's laws.
Under 8 USC 214.1(l) your spouse has 10 day grace period after the L1 status expires and and 60 day grace period should the job the L1 depends on end. These apply to you as well as long as you are married. If you divorce before this, however, you lose your L2 status (and your employment authorization, if you have it) on the day the divorce becomes final. You must leave the US by this date or, if you want to stay longer, you must file a change of status (say, to a B-2 visitor) before this date. Once you've lost your L2 status the visa in your passport becomes invalid too.
After you've left the US you are free to apply for an ESTA and reenter as a Visa Waiver Program visitor.