Both mean „on the way“. So yes, you can use them similarly. :)
However: „unterwegs“ is only suitable for geographical situations, while „auf dem Weg“ is sometimes used in a more metaphorical language. For example if someone was ill and you ask: Bist du wieder gesund? - Ich bin auf einem guten Weg.
Or if it’s about reaching a goal: Ich bin auf dem Weg, xy zu werden/ zu erreichen.
If someone is letting go of old bad habits: Ich bin auf einem guten Weg, xy nicht mehr zu tun.
Hope that helps :)