Unfortunately, renaming a database is really a DBA task. This script blurs those lines between a DBA and a developer and some DBA's aren't going to allow it. So, there's not a good work around.
Having said that, ask your admin if they're willing to set it up as a job with an account that has privileges to run it.
(Note: This assumes you have access to kick off jobs.)
I was able to by do it by adding a step in front to turn on the cmdshell and turn off at the end. Thanks