In a game last week there were two enemies trying to break down a door to get to us. We were at the end of the hall and our Sharpshooter archery Ranger was trying to hit them through a small crack in the door that they made. Is this possible, and if so, what type of penalties would occur? Would that be considered 3/4 cover?
Yes, you can shoot
You don't need sharpshooter to do this, either.
Cover is covered on page 196 of the PHB, and states (emphasis mine):
A target with three-quarters cover has a +5 bonus to AC and Dexterity saving throws. A target has three-quarters cover if about three-quarters of it is covered by an obstacle. The obstacle might be a portcullis, an arrow slit, or a thick tree trunk.
As long as that opening is equivalent to an arrow slit, then 3/4 cover and +5 bonus to AC is how you would adjudicate that scenario.
To give some direction here, arrows slits are typically about 2" in width from the exterior.
If it is smaller than a standard arrow slit, you could increase the AC bonus further, but that would be up to the DM whether or not they'd allow the action itself at that point.
This is a situation that would call for DM judgment, either in the amount of cover afforded, or the imposition of disadvantage on the attack. Going with 3/4 cover provided by the door, or disadvantage on the attack, would allow the player to still attempt it, while making it appropriately difficult.
The entry on cover specifically calls out an arrow slit, which would be comparable to the crack formed in the door:
A target with three-quarters cover has a +5 bonus to AC and dexterity saving throws. A target has three quarters cover if about three-quarters of it is covered by an obstacle. The obstacle might be a portcullis. an arrow slit, or a thick tree trunk. -PHB pg 196
Similarly, the entry on disadvantage from the DMG:
Consider imposing disadvantage when: Circumstances hinder success in some way. Some aspect of the environment makes success less likely (assuming that aspect doesn't already impose a penalty to the roll being made). An element of the plan or description of an action makes success less likely.
-DMG pg 239
Advantage/Disadvantage have been shown to be about equal to +/-5 to a roll, so either would work here.