I just installed an Ubuntu 18.04 server and noticed when using sudo for commands, it would pause for about 10 secs then execute the command.
A quick google found this post, mentioning that if you change the hostname during install, you should manually add the same hostname to the /etc/hosts for 127.0.0.1.
I did this and now sudo commands execute instantly as expected.