I have successfully established a "Wifi Direct" connection to a HP printer in Ubuntu 18.04 following these instructions.
The idea is to have both devices (computer and printer) connected to the same wifi network - namely the one you normally use to access internet on your computer.
(The printer will also show as a wifi network in the computer's list of wifi networks, but you don't need that here.)
After that, go to Printers section, Add, select “Network Printer”, than select "Find Network Printer" and just wait a bit until your printer appears under there.

Then select "Forward".
You will be asked to give it a name etc.
(With my printer I was not asked to enter a PIN in Linux, but this happened in Windows. At that point the printer displayed a PIN number, which then needs to be entered during setting/adding of the printer.)
When the process is successful, the "Wifi Direct" printer appears in the list of printers as a different printer beside the USB connected one.
