Lodging in the area around the Sognefjord in Norway (the area through which the Norway in a Nutshell route goes) can be difficult to find even if you're looking 6-8 months in advance. Flam is the toughest spot because it's where the Flamsbana railroad ends and the Naeroyfjord ferry trip starts. If you want to take the Nutshell trip (it is beautiful) and don't want to do the whole thing in one day, I think your first priority should be figuring out where you want to break that trip and when so you can try to find a place to sleep ASAP. Scandinavia is very expensive, but lodging availability in the cities wasn't much of a problem for me in 2022 or 2023, just being willing to pay for it.
You didn't mention whether you'll be renting a car or using public transportation. It would probably be extremely costly to pick up a rental car in one country and drop it in another; international drop charges are usually horrendous.