There's nothing terribly wrong about changing a page's title if you like, but before you go any further, I think you should carefully consider if this is a good idea. Even if users have a simple way of not answering the prompt, it's likely to cause many users to simply leave your site. New users enjoy their anonymity and many will be reluctant to provide any personal information on their first visit - even just their name. What you're doing is very different than a site that recognizes and greets a returning customer. If you're developing an online store, I would suggest you drop this idea.
But if you decide to continue in developing your script, you'll want to include some way of storing the user's response so that he isn't asked for his name every time he reloads the page in question or visits any other page that includes the same script. A cookie would be the most common method for something like you're doing, and it's probably the most convenient. Good luck!