The best way to learn how to write for video games is to do it. Write, print your work, read it aloud. Reading aloud is critical to develop your text comprehension skills. Do not be shy nor lazy. Read your works aloud!
If you don’t know how to start because you have no time to code or to make a game, don’t worry. Think in the game you love, imagine a situation between two of its characters. The situation can have branches inside, but maximum 2 endings: the good and the bad.
Now it’s time to write your script. Sarah Longthorne released a while ago this fantastic template for branching narrative in visual novels. You may want to start from here. This is one of the best resources I have ever found for free.
If you are thinking in an RPG, of course that will be different from a visual novel. In this case the triggers that bring the story to the players are different.
You should think in those triggers and create your own template!