I am wondering how to change officially someone's hebrew name. I have seen in the Tora that Hashem changes people's names. Like Sarai became Sarah, Avram became Avraham,Yaaqob became Yisrael, Yetkuel became Moshe.
Today to change one's name one goes to a rav (rabbi) although chabad.org says this is only to change the first and main name, otherwise anyone can add a name. It describes the process as follows
When changing a patient’s name, some say that it should be done in the patient’s presence, and with a minyan, after reciting several chapters of the Psalms and praying for the patient. Others say that the name should be changed when one of the relatives is called up to the Torah in shul; he takes hold of the Torah scroll, a mi shebeirach is recited, and then the name is changed.
The 1906 Jewish Encyclopedia says this is usually given in the synagogue when the Torah scroll is taken out of the ark and unrolled. It has the following nusach (formula) to be said
When the Righteous Judgment has already decreed death from illness, behold, our saintly rabbis said: Three things annul the decree; and one of them is changing the name of the patient. We therefore, in conformity with their advice, have changed the name of [mention here the former name] to the name of (mention the adopted name], who is now another person. The decree shall not have any force with regard to him. Together with the change in name, so shall His decree be reversed from justice to mercy, from death to life, from illness to perfect health for [mention adopted name]. In the name of all the sacred names mentioned in this Sefer Torah, and in the name of the angels, the messengers of all healing and salvation, O Lord, send speedily a perfect cure to [adopted name], that his days and years may be prolonged in happiness, in goodness, and in peace, for ever and ever. Amen, Selah.
Finally, R Yehonassan Sasportas at thehalachacenter brings up a source for the name change and different details
The Geonim, as recorded in Rabbeinu Yerucham (28,1), expanded this custom and enacted that it be done by a Minyan and a Sefer Torah. In addition, a special Tefilah called "Metzalin" should be recited. It includes the change of name and a fervent request that the patient recovers speedily and be considered a new person free of the original evil decree. Also, that he may have the opportunity to perform more good deeds and find favor in the eyes of his creator. The Tefilah is concluded with the Bracha of Gomel and the blowing of the Shofar. The contemporary version of this Tefilah differs a little bit in content and omits the Shofar, Sefer Torah and Gomel. It is accompanied by the recitation of select Mizmorim of Tehillim and the Thirteen Attributes of Mercy. It can be found in the Siddur of R' Yaacov Emdin.