As others have already written, both Machzor Vitry and Tur Orach Chayim 295:1 mention the practice of repeating the last verse of Psalm 91, because it gives out a divine name. Some say that we repeat it in order to have 17 verses, just as Psalm 90 has, which corresponds to the value of טוב, good. But at Motzaei Shabbat and bedtime Shema, we start it with the last verse of Psalm 90. Magen Avraham is a bit more detailed, but I needed to consult MYLOR,* who suggested Machatzit hashekel, the work of the 18th century Czech rabbi from Kolin, Rav Shemuel Löw. There are two things in reality:
The last word of Psalm 91 contains 2 letter י:
:אֹ֣רֶךְ יָ֭מִים אַשְׂבִּיעֵ֑הוּ וְ֝אַרְאֵ֗הוּ בִּישֽׁוּעָתִֽי
We repeat it to have 4 letter י (see Magen Avraham), because in the full (מילוי) spelling of the four letter name, there are four letter י (see של"ה as well):
יו"ד ק"י וי"ו ק"י
The trick of Vihi noam is a bit more complex. We need to take again the full spelling of the four letter name, and sum it up letter by letter:
יו"ד = י' + י"ו + יו"ד = 10 + 16 + 20 = 46
ה"י = ה' + ה"י = 5 + 15 = 20
וי"ו = ו' + ו"י + וי"ו = 6 + 16 + 22 = 44
ה"י = ה' + ה"י = 5 + 15 = 20
This sums up to 46 + 20 + 44 + 20 = 130. Psalm 91 has only 112 words, so at the beginning we add the last verse of Psalm 90 that has 12 words, and we repeat the last verse of Psalm 91 that has 5 words. We count 1 for the whole psalm. This adds up to 12 + 112 + 5 + 1 = 130, which corresponds to the מילוי of the four letter name.
* my local orthodox rabbi