There's no way the intent of the post is:
"How do I transfer an illegally copy of a game from a CFW Switch to a OFW Switch?" There's no way
@ereh24 after seeing the question posted this way would expect the answer to be anything more than: "
of course not!".
The Nintendo Switch's system transfer does not transfer games. The transfer is limited to User Accounts and their respective save data. This is all to ensure there's no piracy enabled by this process. This would require a method for injecting games onto OFW Switches (which if possible way less people would have CFW Switches so they could play online with the injected games.) The issue with this is that all games installed onto the system via eShop are issued a unique ID code independent to BOTH the eShop account & console. It's this same ID that the Nintendo Switch Online servers use to detect CFW Switches with pirated games on the system.
So, I will assume you are asking if it's possible to migrate your SAVE for the game to another system.
The answer surprisingily is: YES.
The CFW Switch's internal game database cannot have a history of any pirated games
(so a Recovery Mode Factory Restore OR hetake restore for you before hand) but I play Pokemon Sword & Shield a Cloud disabled game to which I copy my save via the system's Save Data Transfer feature to my OFW Switch once a week even though I play primarily on my CFW Switch for all non-online activity.