I tried to reproduce the same in my environment and got results successfully like below:
I Installed same PostgreSQL server like below:

Check the status of the PostgreSQL using below commend:
sudo systemctl status postgresql-15
And try to disable SELINUX config file, to allow access to connecting postgressql instance like below:
Sudo vi /etc/selinux/config

Check whether firewall is active, and try to disable the firewall like below:
sudo systemctl status firewalld
sudo systemctl stop firewalld
sudo systemctl disable firewalld

Make sure to allow the PostgreSQL connection, change the parameter listen_address make sure to remove # before and restart the sql
vi /var/lib/pgsql/15/data/postgresql.conf

Now When I try psql -u username -h hostname and add client Ip to pg_hba.conf
vi /var/lib/pgsql/15/data/pg_hba.conf

And try to add client authentication, range of IP addresses will be able to access your postgres.
Now, when I tried to login with postgresql in Azure vm it got connected successfully like below:

Reference:
ssh - Can't connect to Postgresql on port 5432