Prior to macOS Ventura and macOS Sonoma if you wanted to rename your Mac’s name you had to open System Preferences and go to Sharing and change the computer name by editing the name from Computer Name’s value.
In macOS Ventura and the upcoming macOS Sonoma you still can edit the name by going to System Settings -> General -> Sharing and change the mane, but there is another way to edit the computer’s name.
Open System Settings and in the General under the About section you can see the details of your computers and in front of the Name you can edit your Mac’s name by typing any name you like:
You can still edit the name from System Settings -> General -> Sharing section if you want.