How to log in after domain has been transferred

It depends on your needs and what your hosting situation is.

You could download the db (and files) to create a local copy of the old site. If you’re just keeping the old site for data, info, and other miscellaneous meta, this would be the best option (IMO). Download the db, download the site’s files, and set up a local copy of the site.

Another possibility would be if you have a static IP. This would depend on your hosting plan and what’s available. Some host provide this for a cost. If cost is not a problem and you can’t/won’t/don’t want to create an offline local copy as mentioned above, you could get a static IP. Then change the site’s settings to use the IP instead of the domain (WP address and site address in Settings > General).

Similar to the above, if you have another domain you can use, use that. Or (and you weren’t totally clear on this in the question), if this is a change where you still have control over the domain, create a subdomain – like https://old.example.com and use that for the old site’s addresses.

Keep in mind, if you leave the site on the general Internet (as opposed to the first option of creating an offline local copy), then you’ll need to consider whether you want it to be accessible to the world or not. If not, then you’ll need to take steps to prevent general access. WP is really good about letting itself be found by bots and spiders, so simply preventing crawling is not a perfect solution. There are plenty of discussions of plugin and non-plugin solutions to keeping a site inaccessible. One that comes to mind would be using a “down for maintenance” or “coming soon” plugin that allows for “dev” access.