This AppleScript will turn on Noise Cancellation if the AirPods are already connected:
tell application "System Events"
tell application process "ControlCenter"
try
click menu bar item "Sound" of menu bar 1
tell window 1
UI elements
tell scroll area 1
click (first checkbox whose title contains "Cancellation")
end tell
end tell
end try
end tell
end tell