Doing the rounds right now is a post from Valve's Steam support, when a user asked about what would happen to their Steam account when they died and it's not great news for anyone hoping to pass on your Steam account.
That said, I'm looking for details for individual games, but odds are, the rules are the same. Yes, you can still do it, but you can on Steam as well and if you're disregarding legality, theres always other options.
Edit 2:
3.3 Your GOG account and GOG content are personal to you and cannot be shared with, sold, gifted or transferred to anyone else.
GOG has always been big on non-DRM and giving you direct access to the installers. They do have a launcher, which likely has similar terms as Steam, but there's no way to enforce the way people use installers.
So it's more similar to physical media--there's still legislation, but I don't believe "passing on" a game would be any more illegal than passing on a physical disk.
And GOG has always been in favor of this model, to my knowledge.
You can literally just download copies of all your games and give them the installers, even if it's in the TOS, there's nothing stopping you from bequeathing them via a drive practically speaking.
The difference is that with GOG once you buy something, you can download it and have it forever, with nothing short of extremely drastic measures that the company can do to remove your access. With steam, all they have to do is just disable your account, and you lose everything.
What physical media? A plastic box containing a slip of paper with a download code? Or at most a disc that doesn’t even contain the full game just part and some activation code to download the rest