You do it from the "Pets" gump.
Your pets gump may be minimized, though. Look for a little circle with an arrow on it if you don't see a gump with a list of all your pets. All you have to do (assuming you aren't running a custom mod that disables pet renaming) is click on the pet's name and type in the new name.
I modded my pets gump to disable pet renaming because I kept renaming pets while trying to target them. It was getting kinda annoying.