You can take a piece of the boat and drop it overboard so the sea gods can record everything. Google will have plenty of renaming ceremony scripts.
I'll tell you though, don't think it gets you out of trouble. Penelope had already been named by a previous owner, but it wasn't displayed anywhere and I never was able to learn of the old name. I did the renaming ceremony and I still had things go wrong.
Popped shroud
Accidental groundings
Motor problems
Fuel leaks
Furler problems (one resulted in nearly tipping the boat off the trailer on a windy day

)
Straps opening and coming loose while going down the road at 60 mph
Involuntary bribes Davy Jones.
Ugh!
I was not a newbie sailor or a newbie to towing trailers/boats.
I think those days are behind me, thank god. She's (or they've) accepted the new name and we're buddies now as long as I don't get too big for my britches. You may have to get through a few hiccups first and you may not.
(FWIW a lot of it had to do with a boat being on the hard too long. The little gal spent half her life on the hard in storage instead of being used so I guess she was pretty pissed off and why not take it out on her new skipper. What an ornery little boat I have.

)