you thought wrong. (turn on GUI scripting first though)
set NewComputerName to "New Name"
tell application "System Preferences" to activate
delay 2
tell application "System Events"
tell process "System Preferences"
set frontmost to true
click menu item "Sharing" of menu "View" of menu bar 1
delay 2
tell window "Sharing"
text field 1
set value of text field 1 to NewComputerName
end tell
end tell
end tell
tell application "System Preferences" to quit