The minchas chinuch (mitzvah 437) discusses the possibility that if one were to erase the name of Hashem for a purpose and not "derech hashchasa" it may not be a violation of mechikas Hashem. Based on this approach he points out that the erasing of Hashem's name by a Sotah would not be a violation at all.
The gemara explains that prior to erasing Hashem's name in the water we try to convince her to admit, but after erasing Hashem's name in the water we try to convince her to drink. Rashi explains that prior to the erasing we take measures to prevent the erasing of Hashem's name and therefore try to scare her out of drinking. This would not contradict the approach of the minchas chinuch, because even according to the minchas chinuch, if we can prevent the erasing of Hashem's name then it would not be necessary to do so and therefore be derech hashchasa, so we try to get her to admit to avoid the erasure.
However, after the name is erased we convince her to drink. According to the Minchas Chinuch the rationale would be simple. If she would not drink, the name would have been erased for no reason at all, but if she would end up drinking then there would be a valid reason for erasing Hashem's name. Therefore we would try to convince her to drink to avoid a retroactive mechikas Hashem l'vatala (Hagahos Ya'avetz offers a slightly different approach, that we convince her to drink because the miracle of the sotah waters taking effect will be a kiddush Hashem to out weigh the chilul Hashem caused by the erasure). Yet, rashi does not explain like this. Rather, rashi implies that the issur of erasing Hashem's name was already violated and cannot be retroactively fixed even if it is done for a constructive purpose. Therefore rashi explains that the purpose in convincing her to drink would be to restore her relationship with her husband on the chance that she is truly innocent (because if she would not drink out of fear, or admit guilt out of fear she would remain assur to her husband forever).
Rashi seems to hold that even erasing Hashem's name for a constructive purpose is a violation (as the gemara implies in succah and sanhedrin when dovid learned a kal v'chomer from achitofel to permit the erasing of Hashem's name to stop the waters from rising).