There are various ways to disable the microphone on an iPhone:
Via the Control Center: Swipe down from the top right corner of the screen on your iPhone X or later, or swipe up from the bottom of the screen on your iPhone 8 or earlier to open the Control Center. Then, tap on the microphone icon to turn it off.
Via the Settings app: Open the Settings app on your iPhone and scroll down to find the "Privacy" option. Tap on "Microphone," then toggle off the switch next to the apps you want to disable the microphone for.
Via Siri: You can turn off the microphone on your iPhone by asking Siri to do so. Simply say, "Hey Siri, turn off the microphone," and Siri will turn off the microphone.
Via the mute switch: The iPhone also has a physical mute switch located on the side of the device. Sliding the switch down will turn off the microphone and prevent any sound from being picked up.
Your iPhone's microphone won't be able to pick up any sound or speech input, which could have an impact on some of its features. When you need to use the microphone, make sure to turn it back on