No, sorry, you don't "own" pirated copies of software. You illegally possess them.
So this whole time you've been thinking about operating systems specifically? You've now totally lost me. You can easily sell both Windows and macOS machines with their respective operating systems installed and that's perfectly legal. I'm talking about application software, such as Microsoft Office, Adobe Photoshop, etc. If you have a physical disk with a license key, then you can sell that without issue because the license key is tied to the disc. However, with software downloaded online, the license is tied to your account, and whether that license can be transferred depends on the license agreement that YOU agree to by purchasing and downloading the software. Again, feel free to cite current US law that you think a software company would be in violation of by prohibiting the transfer of a license.