One of my friends and training partners uses MM and I actually sometimes struggle against this character too. The lemons does a great job of shutting down approach options. So what I like to do against this is run in and shield and just let the lemons take their course. You won't be able to punish them immediately but staying close to Mega Man is important because it doesn't let him set up with his specials, because then he will really be able to keep you away. When you're decently close to him and he does try to setup, then you should be fast enough to just punish him for it; my friend actually tells me he hates fighting Falcons because Falcon is too fast for him and he can't make any mistakes otherwise Falcon will destroy him. You also have to keep in mind that the pellets only do 1%, maybe less. So just stay calm and chill and wait for your chance to strike.
I just now thought of this as I was typing, but maybe perfect pivoting + shielding towards Mega Man while he's shooting will do a good job of blocking the pellets as well as getting closer to him. You can also maybe try running in and rolling behind him but only do that as a mix-up, because he will sooner or later read it and chin-check you with an up-tilt at kill percents. There are multiple videos on YouTube of Fatality vs. Scatt, look them up and see what Fatality does to force himself in.
If you're ever in tournament against a Mega Man, I'd probably suggest you make sure that you do everything to not go to FD/Omega stages. Platforms will help you avoid the pellet spam and will make it easier for you to cross him up. Hope I could help somehow, cheers