...but newer ubuntu versions only have libgdbm6
Indeed: according to https://packages.ubuntu.com/search?keywords=libgdbm5 , libgdm5 is only available in Bionic (18.04LTS), whereas libgdm6 (See https://packages.ubuntu.com/search?keywords=libgdbm6) is available in Focal (20.04LTS), Groovy (20.10) and Hirsuite (21.04).
Consequently, the Focal/Groovy/Hirsuite package repositorios shouldn't have any package that depends on libgdbm5 (or on any non-available package, for that matter).
If you do not have the Bionic repositories configured in your APT instance, there's no way you can install libgdm5, no matter package aliases or virtual (provided) packages.
An approach here would be to add a Bionic repository to yor APT configuration. I suggest you do that by creating a /etc/apt/sources.list.d/bionic.list file and having the relevant deb repo configuration there. The one-liner to achieve this would be
sudo echo "deb http://in.archive.ubuntu.com/ubuntu/ bionic main restricted universe" > /etc/apt/sources.list.d/bionic.list
...followed by apt-get update and apt-get install libgdbm6.
Also remember that, by default, the repositories for your release should have priority over any other repositories defined in /etc/apt/sources.list.d. Do read https://wiki.debian.org/AptConfiguration to have a better idea of how repository priorities work.