It is easily done via hardware, with a < $20 usb wifi adapter
or usb wifi dongle
you can buy off amazon or elsewhere. You would want to choose the correct wifi frequency to have between both devices, 802.11ac is most common currently... both devices must support the wifi standard chosen.
At the hardware level this is rather easy to answer your basic question of Is there a device which can plug into the PC’s USB port and serve a wireless network. Yes, a cheap usb-to-wifi adapter.
To have wifi security and only allow specific devices to connect, that would be done in software on the hosting device, setting up WEP or WPA and an SSID with password to connect.
Like was mentioned in the comment, one of the computers having window10 or later you would make use of the mobile hotspot, which creates the wifi network and will allow the other device(s) to connect to it. How that would be done in linux I don't know.
that only allows talking to a specific port?
hardware-wise, no, everything is built around the OSI model. To restrict ports that will be done in software on the wifi hosting device, typically via the firewall, and doesn't have anything to do with the hardware aspect of the usb-to-wifi adapter.
5 Router OS's that turns Old PC Into High Performance Router And Enterprise Network Switch
https://www.geckoandfly.com/24015/router-os-enterprise-network-switch/