You may want to install PostgreSQL from an official repository, since it is updated more frequently than official Ubuntu sources.
First, you should install prerequisite software packages that will be used to download and install software certificates for a secure SSL connection.
sudo apt install wget ca-certificates
Then, get the certificate, add it to apt-key management utility and create a new configuration file with an official PostgreSQL repository address inside.
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
It is always a good idea to download information about all packages available for installation from your configured sources before the actual installation.