Missing space on GPT drive sharing FAT and APFS volumes
Note: I assume disk2 has a protective MBR which means the drive is not using a GPT/MBR hybrid partitioning scheme. The gdisk command displays the type of partitioning when first invoked, but in your question you choose to omit this output. 


Question: How can I get macOs to actually acknowledge there's 20GB free space?

The Disk Utility application assumes there is never any significant free space on any drive. All successful operations performed using this application always leave the drive with no significant free space.

Of course, drives often have free space. In fact, you can create free space using the diskutil command. Therefore, the Disk Utility application can/should only be used under ideal conditions.

The diskutil list command has never shown free space. There is a limits option for diskutil resizeVolume and diskutil apfs resizeContainer that will display the amount of space that a partition can be expanded into. One can assume this is free space below the said partition.

One command included with macOS, that will show free space, is the gpt command. In your case, you would enter the command given below.

sudo gpt -r show /dev/disk2


The output from gdisk, shown in your question, produced basically the same information the above command would produce.

I used the math below to compute the free space.

629,409,785 - 588,881,912 - 1 = 40,527,872 sectors 
40,527,872 sectors * 512 bytes/sector = 20,750,270,464 bytes = 20.8 GB
20.8 GB * 0.931323 GiB/GB = 22.3 GiB


I used the math below to compute the size of the NTFS partition.

588,881,912 - 264,192 + 1 = 588,617,721 sectors
588,617,721 * 512 bytes/sector = 301,372,273,152 bytes = 301.4 GB
301.4 GB * 0.931323 GiB/GB = 280.7 GiB



  Note: This is the same result the output from diskutil and gdisk show in your question. There is no error here. The problem may be in the way Windows 7 is labeling the partition sizes. Windows 7 may have mislabeled GB for GiB or vice versa.


I used the math below to compute the size of the APFS partition

976773128 - 629409785 + 1 = 347,363,344 sectors
347,363,344 sectors * 512 bytes/sector =  177,850,032,128 bytes = 177.9 GB
177.9 GB * 0.931323 GiB/GB = 165.7 GiB



  Note: 1 GB = 1,000,000,000 bytes and 1 GiB = 1,073,741,824 bytes.


Question: How can I get macOs to add the 20 GB of free space to the APFS partition?

You don't. You can add free space immediately after a APFS partition but not free space immediately before. In your case, the free space is before the APFS partition.

Technically, you could first move the APFS partition to the start of the free space, causing the free space to be below the APFS partition. This would allow you to use the diskutil apfs resizeContainer command to add the free space.

Third party software exists that claims to be able move a partition.  I tried using a bootable USB flash drive containing GParted to move a APFS partition, only to discover GParted does not recognize the APFS format and therefore will not move this type of partition. (To create a bootable USB flash drive containing GParted, I used UNetbootin to transfer the GParted ISO to the flash drive.)

Another option would require another drive with enough free space. The steps are given below.


Backup the APFS partition to another drive.
Delete the APFS partition. You can do this with with diskutil, gpt or gdisk.
Create a new APFS partition to include the free space. You can do this with with gpt or gdisk.


  Note: Make sure the sector values you enter are divisible by 8.

Format the new partition. You can do this with with the Disk Utility applications, diskutil, or newfs_apfs.
Restore from the backup drive.