Depending on what you mean by "realistic", it probably isn't possible.
I don't just mean the damage aspect (for that, see CatLord's answer and look at d20 Ultramodern Firearms), I mean that the existence of modern firearms changes society and also implies a lot of preconditions.
Where do they come from? / The Preconditions
Modern firearms require precision machining. If they are being manufactured locally, especially in large numbers, that implies that the manufacturing ability is far beyond what existed in the Late Middle Ages or even Rennaissance. That implies a lot about society. It practically implies that the industrial revolution has occurred (which in real history was both a precondition for modern firearms and was further spurred on by the process of developping them). That implies a lot of changes in society.
Of course, you could have them imported from somewhere else. DnD cannon, especially Planescape, discusses travel between different realms. That implies smaller changes to society, but then you have your DnD world interacting with a world that has undergone the industrial revolution. That has different, but interesting reprecussions (for ideas, look at many of the first contact stories where aliens come to Earth in an earlier age).
What they do / The Consequences
Mass produced fire arms are very democratizing in a way. They mean just about anyone can reasonably go into a fight with just about anyone else. This wasn't really true with the weapons of the middle ages historically or with DnD. A single peasant simply wasn't a threat to a well armed Fighter or a decent Mage. A single peasant with a gun is.
And a modern weapon of reasonable caliber will go straight through most middle ages armor. So unless magical armor (or modern kevlar) is really common you will have your footsoldiers running around unarmored and essentially developping modern infantry tactics.
Revolutions will be even more common because modern weapons make guerrilla warfare and revolutionary tactics much simpler. They also make it much simpler to recruit an effective army. It takes substantial time to train an archer or a decent swordsman, but I can show someone the basics of firearm use and maintenance in an afternoon (to be clear, I said the basics. Real mastery takes a long time and group tactics take a long time. But I could still get a group of effective riflemen much faster than a group of effective swordsmen)
If firearms are relatively common, then they will dominate and displace all non-magical and even most magical weapons because they are that effective. If they aren't relatively common, then they will be a near dominating force against a force weilding non-magical weapons and a big leveller against magical ones.
If you want to play something that is at least semi-realistic that uses both magic and firearms, you are better off introducing magic to a somewhat real world setting rather than trying to bring fire arms into a magical setting modeled loosely after the late middle ages. Take a look at Shadowrun or Rifts amoungst other possibilities.