Changing Bootcamp Partition ID on Terminal in Recovery Mode
The commands given in this answer should be entered while booted to macOS Recovery. Older versions of macOS (OS X) may require booting macOS Recovery from the Internet or a macOS installation USB flash drive. Also, some commands may need to be preceded by a sudo. The instructions given below will probably fail when hybrid partitioning is being used.

The command provided by macOS to change a partition type GUID is gpt. However, this command works differently from gdisk in that gdisk is interactive and gpt is not. Also, the gpt command requires removal of the partition from the GPT in order to change the partition type GUID. Once removed, the partition can be added back to the GPT with the correct partition type GUID. This removal and addition does not alter the contents of the partition.
The command below can be used to partially view the current contents of the GPT for the drive with the identifier disk0.
gpt -r show /dev/disk0

The commands below can be used to remove from the GPT the partition with the identifier disk0s2.
diskutil unmountdisk disk0
gpt remove -i 2 /dev/disk0

The commands below can be used to add to the GPT the previously removed partition. This partition will be given the Windows GUID type. Replace &lt;start&gt; and &lt;size&gt; with the integer values shown in the output of the command gpt -r show /dev/disk0 for the row with an index of 2.
diskutil unmountdisk disk0
gpt add -i 2 -b &lt;start&gt; -s &lt;size&gt; -t windows /dev/disk0


Note: The integers used in identifiers do not have to match the index values used by the GPT and gpt command. In this case, the 2 used in disk0s2 probably refers to the partition with index value of 2 in the GPT.