In Safari you can change the User Agent string by using the developers option “Develop -> User Agent -> Other”. However, this will change the user agent just temporally. After you restart Safari, the old User Agent string will be used. If you want to permanently change the User Agent string you need to run the following command:
defaults write com.apple.Safari CustomUserAgent "\" your new user agent string \""
To change the default User Agent in Chrome you should create an application with the Automator. Run Automator, select Application as type of document, in the Library search for “Run Shell Script” -> double click, change the cat command with the following command
open -a "Google Chrome" --args --user-agent="your new user agent string"
save it in your Applications folder. Thats it!
If you have a shortcut to your old Google Chrome in the Dock, remove it. Then, start your newly created Chrome application and pin it to the Dock (right click -> Options -> Keep in Dock).
To change the icon of the newly created application you can do the following: right click on the old Google Chrome application -> Get Info -> click on the Chrome icon in the top left corner -> Cmd-C. Then, Get Info on your new application -> click on the icon in the top left corner -> Cmd-V.
Now the user agent string will be the one you wanted!