When on the train from Bergen to Oslo can you get off the train in Myrdal, take the train to Flam, back to Myrdal and back on the train to Oslo? In other words-can you have a stop-over on the Bergen to Oslo train and get back on a later train to Oslo?
I suspect you can do so if you book that arrangement. Otherwise, I suspect not. Our train tickets were for a specific time with reserved seats. If you got off without prior arrangement your tickets might not be valid for a later train.
I would suspect that you need to book Bergen to Myrdal, Myrdal to Falm, Flam to Myrdal then Myrdal to Oslo. The Bergen Line rail requires seat reservations. And from what I have read, advanced bookings Flam Railway is a good idea during peak tourist season.
As said above, you should be able to do what you propose, as long as you're ticketed that way. When I did this in 2003 (in reverse, from Oslo to Bergen), I only needed reservations on the Oslo to Myrdal section, but my understanding is that other sections now need reservations to be sure of getting the trains your want.
However, is there a reason you're not doing the full Norway in a Nutshell route, with the fjord boat and the bus between Gudvangen and Voss? Unless you're seeing these areas on other days in Norway, you're missing some of the best parts of the Bergen to Oslo route.