Is it possible to install macOS onto external SSD on a Mac running Ubuntu?
It is quite simple to install macOS on an external drive using macOS Internet Recovery.


Plug in the external drive.
Turn on or restart your Mac, then immediately hold down ⌘ + R keys.
Release the keys when you see the Apple logo or a spinning globe.
macOS Utilities window similar to the one below will be displayed.





Proceed to erasing the external disk by selecting Disk Utility and clicking continue.
Select your device or volume in the sidebar of Disk Utility.
Click the Erase button or tab.
Complete these fields:


Name: Enter a name for your disk, such as "Macintosh HD".
Format: Choose Mac OS Extended (Journaled) or APFS.
Scheme (if available): Choose GUID Partition Map.






Click Erase to begin erasing your disk.
When done, quit Disk Utility to return to the utilities window. You're now ready to install macOS.
Choose Reinstall macOS (or Reinstall OS X) from the utilities window.
Click Continue, then follow the onscreen instructions. You'll be asked to select your disk. Select the external disk (identify it with the value supplied for Name in step # 8).
Click Install. Your MacBook Air will restart after the installation is complete.




Voila! Your bootable external disk is now ready.

Yes, if you are unable to boot into Ubuntu for whatever reason, you can simply plug in the external SSD with the macOS installed and then press and hold Option (Alt) to boot from the external SSD?

To boot from the external disk:


Turn on or restart your MacBook Air with the external disk connected.
Press and hold the Option key immediately.
Release the Option key when you see the Startup Manager window.
Select your startup disk, then click the arrow under its icon, or press Return.