From: Rabbi Moshe Sofer
To: Rabbi Elyakim Getz Konigsberg
A Sefer Torah contained the word אלים (Elim) where אלהים (Elokim) should appear, omitting the hei. The Chasam Sofer rules that the final letters yud and mem, which carry no sanctity since Elim is not a valid divine name, may be fully erased, and the correct ending hei-yud-mem written in their place with proper sanctifying intent, restoring the word to Elokim.
Source: Shu"t Chasam Sofer YD §273