Cannot remove the bootcamp partition whether with disk utility or terminal

Solution 1:

The OP refers to the the Microsoft Basic Data partition (disk0s3) as the "bootcamp" partition. This partition can not be removed using the Disk Utility application, because the partition in not the next partition after the Apple_APFS partition (disk0s2). In order to display correct output, the diskutil command often requires the partitions to be stored in ascending in the GUID Partition Table (GPT). In the OP's case, this is not true, which caused the diskutil list command to produce the flawed output shown in the OP's question.

To illustrate the problem, I created a sparse disk image which has a partition arrangement similar to the one occurring on the drive described in the OP's question. The identifier assign to this sparse disk image is disk2. The output from the command diskutil list disk2 is shown below.

/dev/disk2 (disk image):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        +251.0 GB   disk2
   1:                        EFI ⁨EFI⁩                     322.2 MB   disk2s1
   2:                 Apple_APFS ⁨Container disk3⁩         177.2 GB   disk2s2
   3:       Microsoft Basic Data ⁨⁩                        73.5 GB    disk2s3
                    (free space)                         177.5 GB   -

Just as in the OP's question, the sum of the individual sizes do not equal the total size. Also in both instances, the output from the diskutil command shows the size sum of the first two partitions equals the size of the free space. This is shown below.

      OP's Question                My Answer
------------------------    ------------------------
    0.3 GB -> disk0s1           0.3 GB -> disk2s1
+ 180.0 GB -> disk0s2       + 177.2 GB -> disk2s2
----------                  ----------
  180.3 GB -> free space      177.5 GB -> free space

Just as in the OP's question, the Microsoft Basic Data partition can not be removed using the Disk Utility application. Below is a image of the Disk Utility application showing the grayed out - button.

Since I am using a sparse disk image, I can enter the command gpt -r show /dev/disk2 while booted to macOS. This command shows the partition location data stored in the GPT. The output is shown below.

Note: The OP would have to boot to macOS Recovery or from a macOS installer in order to execute a similar command.

gpt -r show /dev/disk2
      start       size  index  contents
          0          1         PMBR
          1          1         Pri GPT header
          2         32         Pri GPT table
         34          6         
         40  143564800      3  GPT part - EBD0A0A2-B9E5-4433-87C0-68B6B72699C7
  143564840     629200      1  GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
  144194040  346040342      2  GPT part - 7C3457EF-0000-11AA-AA11-00306543ECAC
  490234382         32         Sec GPT table
  490234414          1         Sec GPT header

The above output shows the partitions are not stored in ascending order in the GPT. The diskutil command is incorrectly displaying the first two partition entries as occurring before the third partition entry. Also, the diskutil is showing the space occupied by the first two partition entries again as free space occurring after the third partition entry.


Since the Microsoft Basic Data partition (disk0s3) occurs before the Apple_APFS partition (disk0s2), the space occupied by the Microsoft Basic Data partition can not be merged back into the Apple_APFS partition. The OP needs to backup important data, erase the drive and reinstall macOS.

Appendix

The table below show selected equivalents between the types displayed by the diskutil command and the GUID partition type value stored in the GPT.

diskutil Type Partition Type GUID
EFI C12A7328-F81F-11D2-BA4B-00A0C93EC93B
Microsoft Basic Data EBD0A0A2-B9E5-4433-87C0-68B6B72699C7
APFS 7C3457EF-0000-11AA-AA11-00306543ECAC