If the odds are that stacked in favor of either side, don't call for a roll
The Basic Rules pg. 58 and Player's Handbook both describe ability checks with the following prelude (emphasis mine):
The DM calls for an ability check when a character or
monster attempts an action (other than an attack) that
has a chance of failure. When the outcome is uncertain,
the dice determine the results.
When cumulative advantages stack that heavily against the player characters, the outcome is not uncertain; the player characters shouldn't succeed. So instead of letting them roll, just tell them that the task is impossible.
Similarly, if they have so many advantages stacked up on their side that it seems ridiculous that the PCs have a chance to fail, don't have them roll at all; just declare that they succeed. So in the case of your DC 30 portcullis trap, if you feel that the combined strength of the player characters is enough to lift the portcullis, then don't roll and instead declare that they succeed in lifting the thing.
In this way, you are only rolling for contests which are possible at all and don't have to worry about situations in which either PC success or failure is almost impossible to justify.
But what if their combined strength is only enough to justify a chance at success?
You may end up in situations, like the trap you describe, where the combined effort of every PC is enough to have a chance to succeed, but is not enough so that success is guaranteed. In this case, there aren't really many rules to help you. 5e is designed with simplicity at heart, so there are no rules for circumstantial bonuses. With that said, you are the DM and you have control.
In the same ability check section, the basic rules and PHB say:
For every ability check, the DM decides which of the six
abilities is relevant to the task at hand and the difficulty
of the task, represented by a Difficulty Class.
You are in control of the DC, and you get to decide what it should be. You can even decide to change it on the fly to make your game work for you. We essentially solve the problem in reverse. Instead of looking for rules to modify the bonus to the roll, we leverage the power the rules give us as a DM to modify the target number.
You have every right to change the DC to whatever value you feel is most appropriate.
For example, 5 people lifting a portcullis might not be impossible, it might just be hard. So you can adjust the DC down from 30 to ~20 (based on the chart on typical difficulty classes in the basic rules and PHB).
You can even choose values between these markers. So, the task might be more than medium but not quite hard. In that case, you can decide "five people makes this a DC 17 or 18, not a 30". And then you can use either one roll from one of the players (with or without advantage at your discretion) or the group check rules now that the goal is much easier for everyone in the party to make.
This is the approach I use the most often in situations like these and I firmly believe that it's much less of a headache than trying to deal with rules for circumstantial bonuses.
Best Answer
Helping is straightforward in most circumstances, but it can get complicated
There are two primary ways that you can assist someone in D&D 5e:
Both of these options are pretty straight-forward.
Granting them advantage on their roll
The rules on working together state:
So, the anatomy of this is:
Participating in a group check
The section continues by presenting the rules on group checks:
The only question here is what happens if we have an odd number of characters in the group?
Well here, one of the general rules listed at the start of the PHB applies: Round down.
So, a group check with three participants only requires one of the three participants to succeed for the group to succeed. If you have four participants it requires two to succeed, and so on.
But, for your specific situation there is more to the story than just the straight helping rules.
In your specific example, the general rules on the Strength ability would also apply, in particular the lifting and carrying rules:
In the situation described your two PC characters are attempting to drag the flying creature down to prevent it getting away, while the flying creature is attempting to lift your characters (i.e. continue flying). How much a creature can drag/lift is determined by it's size and strength score.
But is there a precedent for using the rules in this way?
Yes, in a number of the adventures published by WotC (Tomb of Annihilation, Out of the Abyss, Waterdeep: Dungeon of the Mad Mage, Divine Contention, Tales from the Yawning Portal to name but a few), there is text to the effect:
This mirrors what we see in our own world, where one person cannot move a heavy thing, but many people can easily move a thing with their combined strength.
How do we resolve this?
The game has a general rule for whether or not we even get to roll dice to make an ability check:
The DMG (p. 237) also provides some guidance on how to adjudicate in these sorts of situations:
So, in order to decide if a roll is required we need to determine if the task being attempted is possible (for both sides). To do that we need to compare the total drag capacity of the PCs (or their combined weight, whichever is higher) against the total lift capacity of the flying creature.
The DM might also decide to use the Variant: Encumbrance rules presented in the Strength section to determine if the creature can fly with all of the weight it is trying to lift:
So we have two options:
One side domination...
If one side clearly outmatches the other then no die roll is required for the opposed strength check, the contest is clearly won. For example if your two PCs are attempting to drag down a Roc by grabbing onto it's claws they will fail, but if a grappled flying creature is a bat it will clearly fail.
This, of course, does not preclude the grappled creature from attempting to escape the grapple:
It is possible for a creature to use the Help action to grant the grappled creature advantage on their roll to escape the grapple. It's even possible, if the DM is using the Encumbrance rules, that the flying creature has disadvantage on it's strength check to try maintain the grapple.
It's close...
If instead the two totals are close (for some definition of close determined by the DM) then a Strength or Athletics contest is appropriate. 5e has rules for ability check contests:
In this case, your PCs are attempting to prevent the creature from flying away. Combining everything we have found the result is:
tl;dr
To resolve the situation: