So in a version of Unity 2017, the ability to switch microphone devices broke. It just got fixed in a recent version of Unity but the project can’t really be upgraded anymore (the bug happened in 2017, and got fixed in 2018).
Is there a way to just overwrite the Microphone source code in Unity with the updated version?
There’s no such thing, but it’s a matter of definition of terms. Source code can’t be patched into a running application the way you’re thinking - source code creates binary output (or bytecode, it depends on the language, but Unity is written in C++).
There’s no real way to do what you’re requesting. It would require Unity to publish an update for 2017, but I doubt that’s happening. You could check to be sure the last 2017 version does or doesn’t have the bug fix (doubtful), but beyond that, you’ll have to consider moving the project to 2018.