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.

Computer Name field in macOS Monterey Sharing preferences

In macOS Ventura and the upcoming macOS Sonoma you still can edit the name by going to System Settings -> General -> Sharing and change the name, 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:

Editing the Mac name in System Settings, General, About in macOS Ventura
New Mac name entered in the About section of macOS Ventura System Settings

You can still edit the name from System Settings -> General -> Sharing section if you want.

Local hostname in System Settings, General, Sharing in macOS Ventura