Mute Phone Mic when Headphones are Plugged In?
You might try an app called Pilfershush.
It takes control of the microphone so that other apps can't use it.
Just remember to turn it off before you try to use the phone for a call.
PilferShush Jammer (Block unwanted use of onboard microphone) - https://f-droid.org/app/cityfreqs.com.pilfershushjammer