Not if you want to meet any accepted definitions of open source.
In the OSI definition, clause 8 addresses this specifically:
- License Must Not Be Specific to a Product
The rights attached to the program must not depend on the program's being part of a particular software distribution. If the program is extracted from that distribution and used or distributed within the terms of the program's license, all parties to whom the program is redistributed should have the same rights as those that are granted in conjunction with the original software distribution.
The FSF defines a set of rights that have to be met for them to consider the software free. Right 0 reads:
The freedom to run the program as you wish, for any purpose
Restricting the use to a specific operating system violates this right.
You could frame a license with this restriction in it, but it wouldn't be open source.