I have recently came across this on Ubuntu 20.04 TLS and found the solution.
$ man -k umask
$ man pam_umask
This will get us the location of manual pages that discuss umask - all information can be found there.
From /etc/pam.d/common-session:
The pam_umask module will set the umask according to the system
default in /etc/login.defs and user settings.
This solves the problem of different umask settings with different
shells, display managers, remote sessions etc.
From PAM_UMASK(8):
pam_umask is a PAM module to set the file mode creation mask of the
current environment. The PAM module tries to get the umask value from
the following places in the following order:
umask= entry in the user's GECOS field
umask= argument UMASK entry
from /etc/login.defs (influenced by USERGROUPS_ENAB in
/etc/login.defs)
UMASK= entry from /etc/default/login
Notice the text in the brackets: influenced by USERGROUPS_ENAB in /etc/login.defs.
What is USERGROUPS_ENAB?
From /etc/login.defs:
If USERGROUPS_ENAB is set to "yes", that will modify this UMASK
default value
for private user groups, i. e. the uid is the same as gid, and username is
the same as the primary group name: for these, the user permissions will be
used as group permissions, e. g. 022 will become 002.
In not specified, the permission mask (umask) is initialized to 022.
You can now run this:
$ sudo nl /etc/login.defs | grep USERGROUPS_ENAB
to double-check if you have USERGROUPS_ENAB set to "yes", if it's uncommented (default), and on which line of the document can you find it.
Therefore, when you change the default "UMASK 022" to "UMASK 027", if USERGROUPS_ENAB is set to "yes", you will see that your umask has been set to 007 (not 027) - as it ignores the 2nd position (group permissions).
The solution to this is simple: uncomment the line where "USERGROUPS_ENAB" is set to "yes". If you have changed umask value to "UMASK 027", you will have umask set to 027 after the reboot.
You can verify this by running this in your shell.
$ umask
To summarize, the only config file that matters is /etc/login.defs.
Set your umask to desired value and make sure to uncomment USERGROUPS_ENAB line to change group permissions as well.
Hope this helps.