DISCLAIMER: I DIDN'T WANT TO INSTALL IT IN DUAL BOOT ON THE MAIN DISK
I wanted to install Ubuntu on a USB stick, so I took two of them, let's call them sdc and sdb, formatted them, mounted the Ubuntu ISO on sdc and booted it. I, then, chose install Ubuntu and selected a normal installation. After that, I created two partitions on the sdb, one of 6GB with ext4 and mounted on /, the other with all the left GBs with FAT32 on /ubuntu as shown in this guide. Then I selected the bootloader to be on sdb and installed it. It took some hours, then I rebooted the pc and all I got was something like this. So I restarted the pc, went into the UEFI and saw a boot option called ubuntu on the local disk that was the first one.
After this, I managed to boot into Windows by putting Windows Boot Manager on top of the boot options and I also deleted the ubuntu option. I then shift-restarted to the sdb stick and Windows booted, like nothing happened. I also wentagain to the UEFI to put the sdb option to the top and Windows booted this time too, the USB was ignored.
In UEFI mode, the Ubuntu bootloader will always be installed into the first drive, which is usually an internal drive. If you want to get the [UEFI] bootloader (which is a partition) into a USB drive, you can unplug, disconnect or otherwise disable the internal drive.
In BIOS mode alias CSM alias legacy mode you can control where Ubuntu installs the bootloader. But it is always a good idea to unplug, disconnect or otherwise disable the internal drive in order to get the bootloader into the USB drive, when that is what you want.
See the following links,
If disabling the internal drive is not an option, on one of the Pages sudodus mentions there is another method described for installing to USB.
It uses a BIOS/UEFI boot template that flashes the boot partitions to the drive.
The OS is then installed to a third partition and boots using the preinstalled partitions.