If you change the script name, a duplicate script appears and you can delete the old one on the “entities” tab.
Settings / Automations & Scenes / Scripts / 3 dots at the back of a script / Show info about script / Tab: Entity setting / Entity id: change this value
If you restart Home Assistant (Settings/System/Restart) a 2nd script with the same name appears in the scripts list. The new named entity id you can edit / use now.
How to delete the old one.
Settings / Devices & Services / Entities / Search Entities: “old entity name whom gives the error “Only scripts inside scripts.yaml are editable.” / has a red “restored” icon at the back / select and delete.