In the dictionaries, the Sanskrit name राम (Rāma), together with most other Sanskrit words, is given in the form of the stem. राम (Rāma) is the stem, and in a sentence it can be used only as a direct address (like in “Rāma, come here!”) since the Vocative case of this noun coincides with its stem. This stem, since it ends in -a, belongs to the so-called a-stems, and when used in a sentence as a member of the sentence, the stem should take up the form of one of the cases according to the role of the noun in the sentence. In your sample sentence, this word is the subject, so it is in the Nominative case, रामः (Rāmaḥ). The next word begins with ल (l), so applying the sandhi rules we get aḥ + l = ol, that's why in your sentence the name राम (Rāma) is in the form रामो (Rāmo).
As for the second name you suggest, राम् (Rām), there is a problem. If we suppose राम् (Rām) is a stem, then we are posed with the fact that Sanskrit has no stems ending in -m. Sanskrit does have consonant stems, that is, stems ending in a consonant, but not in -m and there are no stems with a long vowel before the final consonant… The closest to this are the noun an-stems ending in -an, like राजन् (rājan) m. “king”, which in the Nominative case drop the final -n and lengthen the final vowel (राजन् rājan > राजा rājā). But if we analogize राम् (Rām) to राजन् (rājan) and drop the final -m to make the Nominative case form, what we are left with is just रा Rā.
On the other hand, if we assume राम् (Rām) is a noun already in the Nominative case form, then it also comes out awkward, since in Sanskrit only neuter gender nouns have -m as the Nominative case suffix (cf. Latin “bellum” neuter gender “war”), and a personal name in the neuter gender is something that can hardly be found in languages with a separate neuter gender. Irrespective of whether we consider राम् (Rām) a neuter-gender noun or a borrowed (e.g. from Hindi) masculine indeclinable noun, in your sentence its final म् -m will turn into an anusvāra before ल (l): राम् Rām > रां Rāṃ, exactly as it was correctly noted by @user6726 and @JanusBahsJacquet.
Generally speaking, there is no sense in using barbarisms, nonstandard words regarded as an error in morphology, especially when the barbarism is of the same root and the same part of speech as the existing word in the target language. Moreover, when the barbarism (राम् Rām) is obviously an etymological derivative of a word in the target language (राम Rāma). In such cases, a foreign name takes the form used in the target language, especially when there is no tradition to use that word as an explicit barbarism. For example, we can use analogy of Latin and English. If you wanted to write a sentence in Latin about one John, what would you do? How will you spell [dʒ] in Latin? Will you decline “John”? If so, after which declension? 2nd declension, like phænomenon? Then the Genitive case form is something like “Jī” and Dative “Jō”. But usually it is done in a different way. Latin has the personal name Iōannēs from which the English name John ultimately derives, it is this Iōannēs which is usually used when writing in Latin about a John, for example: Ioannes Lennon, Ioannes F. Kennedy. Translating personal names is widespread across languages, so there is no sense in using राम् Rām in a Sanskrit text, since Sanskrit for राम् Rām is राम Rāma which is a regular noun that poses no problems.