Bergen and Trondheim are a distance of 700 km (435 mi) apart, which is covered by several transportation options. Each option has its pros and cons, though, so take a look and pick the way that's best for you to get from Bergen to Trondheim (or from Trondheim back to Bergen).
This is a quick way to get to Trondheim (or back to Bergen). Direct 1-hour flights connect these Norwegian towns multiple times a day, most are offered by the airlines SAS, Widerøe Airlines, and Norwegian. Weekdays are cheaper than weekend flights between Bergen and Trondheim.
You have two options when it comes to driving this route, both take about 10 hours.
The first route takes you along the coastline and includes a ferry. Take the E39 north (the short Oppedal-Lavik ferry is on this part of your route) and turn onto road 60 after passing through Byrkjelo. Turn on road 15 then, to head toward Stryn and Strynvatnet. Turn off road 15 toward Sel and merge onto the E6 going north from there until it ends in Trondheim.
The second route to Trondheim does not include a ferry. It's not as scenic but easier to drive and you'll avoid the wait and payment for the ferry. Drive on the E16 east all the way to Tretten, and then simply merge onto the E6 north to Trondheim.
Taking the train from Bergen to Trondheim is very scenic and a great experience but only for travelers that have lots of time. You'll spend over 15 hours on the train journey. It also costs a bit more than flying. The overnight train is cheaper, but that also means limited daylight for this scenic trip. The daytime train costs twice as much.
With an overnight travel time of 14 hours between Bergen and Trondheim, the Bergen-Trondheim Express Bus is not a very scenic nor attractive alternative. The train has similar pricing and is more comfortable.
If you're thinking about traveling on a cruise ship from Bergen to Trondheim, know that Hurtigruten (the cruise operator connecting these cities) is slow and very (!) expensive, especially if you're traveling as a family. Be prepared that the weather in Norway might not cooperate and may mean some rough going. Have a backup plan.