In our Gemara on Amud Aleph, we learn about a specific mistake that can occur when writing the Tetragrammaton in a Sefer Torah and the circumstances under which it can be corrected:
The baraisa teaches: If a scribe writing a Torah scroll reaches a point where he needs to write the name of God, spelled yod, heh, vav, heh, but instead intends to write "Yehuda," spelled yod, heh, vav, dalet, heh, and mistakenly omits the dalet, inadvertently writing the name of God (but now missing proper intent), he should pass over it with a reed pen. The scribe writes over the mistake, sanctifying it with the intention of writing the name of God. This is the opinion of Rabbi Yehuda. However, the Rabbis say that even if a second layer of ink is added, it does not fulfill the optimal manner of writing the name. According to Rabbi Yehuda, one can still supply the intention of writing the name of God even when adding a second layer of writing, but according to the Rabbis, this is not possible.
The Gemara explains that the opinion of the Rabbis is based on the principle of "This is my God, and I will glorify Him" (Exodus 15:2). They argue that this form of rewriting is not considered proper and violates the directive to glorify God.
This application of the principle of Hiddur Mitzvah is interesting. Normally, Hiddur Mitzvah is understood as an additional requirement that enhances the performance of a Mitzvah, but does not invalidate it, if not fulfilled. As stated in Gemara Shabbos (133b), there is no limit to how much beauty or adornment can be added to enhance a Mitzvah. However, the lack of Hiddur Mitzvah does not invalidate the Mitzvah itself. The Shulkhan Arukh (OH 656:1) also codifies this concept, stating that Hiddur Mitzvah is an additional requirement to beautify the Mitzvah but not a fundamental requirement. So why is this case different?
The Chasam Sofer provides an explanation for our Gemara. When it comes to writing God's own name, the most proper way of writing it is the only acceptable way. He suggests that this is because the literal meaning of the verse "This is my God, and I will glorify Him" is fulfilled by actually glorifying God and not just metaphorically glorifying Him through the beauty of the Mitzvos. Therefore, according to the Rabbis, if the writing is not done in the proper manner, the Sefer Torah will be invalid.
It is still challenging to understand how the Gemara derived this distinction from the verse. However, I would like to add an additional point to build upon the explanation given by the Chasam Sofer. Another derash derived from the verse relates to the degree of prophetic perception experienced by the Jewish people at the Red Sea. The phrase "This is my God" implies that they were able to point Him out and almost see Him:
"This is my God" - In His glory, He revealed Himself to them, and they pointed to Him with the finger, exclaiming, "This is my God!" A maid servant beheld at the Red Sea what even the prophets never saw. (Shir HaShirim Rabbah 3:15 and Rashi Shemos 15:2.)
Based on this, we could argue that if this verse refers to the clearest possible perception of God, then a similar requirement for clarity would apply.