Method is quite simple, altough you need to implement some color maths to achieve it. Generally steps are these (loop over every pixel of an image, or write a fragment shader if you need it real time):
Convert color into hsv (hue saturation value)
If hue is in certain range, leave color as is.
Else set saturation to 0 and convert color back into rgb.
Godot has inbuilt tools to convert to and back from hsv in Color class, but if you want to make it with shader, you need to write the conversion yourself. You can google for rgb to hsv conversion algorithms, there's good explanations and code examples how to achieve this.