UWPHook can import Xbox/Windows Store (GamePass) games into Steam (as non-Steam shortcuts). They're just normal exes so adding them is easy. Steamsync can import Epic Game Store games into Steam (as non-Steam shortcuts). Enter that into steam and it should work as a non-steam game. You can use software such as the standard Task manager or the more extensive Process Explorer to figure out the command line to start the game. You can of course always add the executable as a non-steam game to steam, but you: (Although modern consoles are all x86-based so porting games for them should be easier). Console versions will not run on a PC without some extensive modification. I'm assuming here that you have access to a PC version copy of the game you want to transfer by the way. For example, Bethesda has provided steam keys to purchasers of Fallout 76 on the Microsoft Store, but Rare has not done so for Sea of Thieves, for two recent examples. It's highly unlikely 'all' games will provide such a key.
The correct answer to this is: it depends on the developer.