I use a Policy that runs the script below to name our MacBooks to the machine's S/N that runs after enrollment and lately it stopped working. It might be since Ventura came out or one of the revision, but I cannot confirm. I can run the commands manually so they commands haven't changed. Any suggestions would be great.
#!/usr/bin/env bash
# Get the Serial Number of the Machine
sn=$(system_profiler SPHardwareDataType | awk '/Serial/ {print $4}')
# Set the ComputerName, HostName and LocalHostName
scutil --set ComputerName $sn
scutil --set HostName $sn
scutil --set LocalHostName $sn