I've spent the last three years building a game engine specifically to do this, and currently finishing the final draft for the game story I've created to go alongside it.
Happy to share anything you'd find helpful. The big takeaway for me has been, you're going to want to graph out the impact of choices before you write the story. If you know the flow of decisions, then that gives a much clearer structure than trying to write the story first and then create branches off it. I think the reason is that it sets a much tighter scope for the writing doing it that way, whereas if you write the story and then find ways to branch it, the scope for that is functionally infinite.
Happy to share anything you'd find helpful. The big takeaway for me has been, you're going to want to graph out the impact of choices before you write the story. If you know the flow of decisions, then that gives a much clearer structure than trying to write the story first and then create branches off it. I think the reason is that it sets a much tighter scope for the writing doing it that way, whereas if you write the story and then find ways to branch it, the scope for that is functionally infinite.
Got any specific questions?