You haven't said why you want to install an OS for one computer by using another one. Without that information, I can't evaluate whether your reasons are good. Odds are they aren't, though. EFI (which all Intel-based Macs use) is different enough from BIOS that BIOS tricks people have picked up over the years don't apply, and trying to use those tricks can in fact imperil your ability to boot. The key problem is that EFI-mode booting involves both disk-based information and information stored in the computer's NVRAM. Although installing Ubuntu using your Mac's disk installed in your HP can create perfectly acceptable disk information, it won't touch your Mac's NVRAM, leaving you with an incomplete boot loader installation. Furthermore, if your HP is also (U)EFI-based and you remove its hard disk, its firmware may notice that its own boot entries are missing and delete them. Thus, you risk not only a failed Ubuntu installation on your Mac, but your ability to boot the HP, as well! There are ways around these limitations, but without knowing why you want to do what you suggest, I'm reluctant to write a lengthy response telling you how to do it, particularly when following my instructions might just make matters worse for you.
My hunch is that you're trying to work around a problem booting the Ubuntu installer or a post-boot problem that's causing your installation to fail. If so, please post a new question describing the problem you're having. Chances are there's a much better solution than what you're trying to do.