Can I convert a game code from one PC platform to another?

In the general case, if a PC game redeem code is restricted to one Operating System only then it is unlikely there is any way to change or transfer it directly.

Your best bet is to contact the place from which you purchased it and request a replacement code for the PC platform you intended to buy, or a full refund.

Do note that this should be a rare occurrence - if a game is stated to run on multiple OSs and it's managed by any of the major PC game platforms (Steam, Origin, Battle.NET etc), it's likely that the code will not be locked to a particular OS; so long as you log in with your account you will have access to download, install and play the game on any type of PC that it supports.