Hi,
Unfortunately, it is not possible to modify an ad through AdWords Scripts, thus you won't be able to set the final URL. You would have to delete the ad first, then recreate it. This follows the same workflow as the AdWords UI.
Let me know if you have any other questions,
Tyler Sidell
AdWords Scripts Team