Can't delete Linux partition with Disk utility
The partition type for the APFS partition has the incorrect value. 

The simplest solution would be to use the gdisk command supplied with Ubuntu to correct this problem.

If you can boot to Ubuntu from either the internal drive or from a live version, then proceed as follows.


Boot to Ubuntu.
Open a Terminal windows by entering the key combination control+option+T.
In the window, enter the following command.

sudo gdisk /dev/sda

Enter the following commands into gdisk. Basically, you will be changing the partition type to the correct GUID.

t
2
7C3457EF-0000-11AA-AA11-00306543ECAC
w
y



  Note: If you are using version 1.0.4 or newer of gdisk, then you can substitute af0a for 7C3457EF-0000-11AA-AA11-00306543ECAC

Quit the Terminal application.
Reboot to macOS. You may need to hold down the option key at startup and then select macOS.


Removing Linux without Using the Disk Utility Application.

When removing partitions, entering commands in a Terminal application window can provide more satisfying results than relying on the Disk Utility application.

A linux partitions can be converted back to free space by entering the commands below.


Use the command below to get the identifier of a partition.

diskutil list

Use the command below to remove the partition. Replace  diskXsY with the identifier determined in step 1.

diskutil eraseVolume free none diskXsY



When finished removing partitions, the free space should be allocated back to macOS. In your case, this can be accomplished using the command given below.

diskutil apfs resizeContainer disk0s2 0


Alternate Method of Employing gdisk

The gdisk command can now be accessed by a rEFInd bootable USB flash drive. Below are the instructions for creating the bootable flash drive.


Goto the website The rEFInd Boot Manager:
Getting rEFInd.
Click on the link labeled A USB flash drive image file. Currently, this will download the file refind-flashdrive-0.11.3.zip, which defaults to the creation of the folder refind-flashdrive-0.11.3 in the Downloads folder.
Insert a flash drive in a USB port. Note: All the files on this flash drive will be erased.
Open a Terminal application window.
Enter the command below to get the identifier of the flash drive.

diskutil list

Enter the commands below to copy the image to the flash drive. If necessary, replace disk1 with the identifier from the previous step. Also, make the appropriate substitution, if your rEFInd version is be newer than 0.11.3. 

cd ~/Downloads/refind-flashdrive-0.11.3
diskutil unmountdisk disk1
sudo dd if=refind-flashdrive-0.11.3.img of=/dev/disk1



Next, follow the steps below fix the partition type error. 


Restart the Mac and immediately hold down the option key. 
Select the external drive icon labeled EFI Boot.
From the rEFInd menu, select the icon labeled Start disk partitioning tool.
Enter the commands given below.

t
2
7C3457EF-0000-11AA-AA11-00306543ECAC
w
y

Select the icon labeled Reboot Computer.