For example there is a video game series called LocoRoco, and in katakana it is spelt (ロコロコ) but the "ロ" character is supposed to be pronounced as "ro" so it sounds like "rokoroko". When translating something to English, when do you replace the "R" sound with a "L" sound?
R is the default consonant to represent the sounds of ラリルレロ using the English alphabet. All the common romanization systems use only R.
The use of L is somewhat exceptional. The most common reason for using L instead of R is that the sound derived from, or is associated with, some Western word containing L. For example, リリアン in this franchise is translated as Lilian, not Ririan, because this リリ is clearly from English lily and it is an important motif in the story.
I could not find the etymology of ロコロコ on the net, but I guess either the original creator or someone from the translation team came up with the idea that ロコ can be associated with locomotion in English. This also explains why C is used instead of K to represent the コ sound. Please don't ask why they used L only for the first ロ. It is up to the translator. Especially in game localization, anything can happen at the discretion of translators, and it is even common to ignore Japanese names altogether (see this list of Pokémon names).