@osxadmin I do that all by hand since I only have to do it occasionally. Here's something I whipped up really quick though. This is NOT tested so you'll need to test.
#!/bin/bash
# Purpose: Casper Self Service script to rename an AD bound Mac
# Author: Steve Wood (steve.wood@omnicomgroup.com)
# Date: 10 Feb 2017
# Version: 1.0
# variables
LOGPATH='<yourloggingpath>'
if [[ ! -d "$LOGPATH" ]]; then
mkdir $LOGPATH
fi
set -xv; exec 1> $LOGPATH/renamelog.txt 2>&1
version=1.0
CD="<yourpathto>/cocoaDialog.app/Contents/MacOS/cocoaDialog"
# grab the new computer name using cocoaDialog
newName=`$CD standard-inputbox --informative-text "Please enter the new computer name:" --float`
newName=`echo $newName| awk '{ print $2 }'`
# unbind
dsconfigad -remove -user '$4' -force -password '$5'
# rename
jamf setComputerName -name ${newName}
# bind
### You can use the jamf binary to do this as below:
### jamf bind -type ad -domain <domain> -username '$4' -password '$5' -ou <Computer OU>
### or setup a policy with either a custom trigger or no trigger and use the ID which is what how I do it
jamf policy -id <pollicyid>
# recon
jamf recon
exit 0
You'll want to add that to your JSS and then add to a Policy that is Self Service triggered. In the 4 parameter box put the user name with bind rights in AD, and in 5 the password.
You'll also need cocoaDialog on that machine. Or, you can re-write the section about getting the new name using AppleScript instead, or if you want to hardcode the computer name, pass that as a variable as well.