I saw a question similar to mine but it was 7 years old so I'm hoping there may be an update to the answer
I would like for my Note 9 running Android version 10 to mute the mic on the phone when I have my headphones plugged in. It seems like it takes sound from both areas and I have my phone setting right next to my keyboard. When I am typing while talking, the sound of the keyboard clicks are extremely loud to the listener. I cannot move my phone as the conversations are typically video calls and I am using a wired headphone connection. Additionally, when I talk while in a somewhat noisy area, the phone mic seems to be more sensitive to the background noise and quiets my voice via the headphone.