When you Wild Shape/Polymorph you "assume the beast’s hit points" thus essentially creating a new, separate pool of HP from your own, original form similar to how Temporary Hit Points work, as Alexis Wilke has stated.
Damage taken in animal form doesn't affect your original form's HP unless you're dropped to 0 HP in animal form and there's excess damage. Nowhere is it suggested that max-HP reduce would work any differently. Because Wild Shape/Polymorph gives you a new pool of HP (as supported by Jeremy Crawford in the link below), only that pool is affected by the reduction.
So, using your example, if a PC has 30 HP in their original form and transforms into a beast that has 50 HP, the PC effectively has 50 HP. If the PC has their max HP reduced by 30 while transformed then they don't die as a result of having 0 HP because they're using the beast's HP and they still have 20 HP left in that pool.
As for whether the max HP reduction carries over to your original form when you revert, according to Jeremy Crawford, lead rules designer, the answer is no:
Jonathan Longstaff
@pukunui81
@JeremyECrawford What happens when a wildshaped druid that has had its HP max reduced reverts back to normal? Does the reduction carry over?
Jeremy Crawford
@JeremyECrawford
Wild Shape—a reduction to hp maximum doesn't carry over from your beast form to your true form or vice versa.
The spell is still affecting the druid, and wild-shaping does not end effects on the wild-shaper, therefore the druid is still under the effects of the enlarge spell while wild-shaped.
At this point you might conclude that the question is settled: they would be an extra-large bear, because the spell is still working that that's what enlarge does. But that's not quite right.
Let us look at precisely what the enlarge spell's effect is, not what we might be tempted to mentally simplify it as (with all emphasis mine):
You cause a creature or an object you can see within range to grow larger or smaller for the duration.
Okay, so it doesn't make it 2× in every dimension as a static fact, it makes it grow at the beginning of the spell. That would mean it would not make any further changes afterwards, only sustain the initial change.
Well, maybe I'm reading too much into "to grow". Let's see what else it says it does:
The target's size doubles in all dimensions, and its weight is multiplied by eight. This growth increases its size by one category — from Medium to Large, for example. If there isn't enough room for the target to double its size, the creature or object attains the maximum possible size in the space available. Until the spell ends, the target also has advantage on Strength checks and Strength saving throws. The target's weapons also grow to match its new size. While these weapons are enlarged, the target's attacks with them deal 1d4 extra damage.
So it does look like it's a one-time growth, based on the verbs and nouns used. In particular, if enlarge is used on a target inside a smaller space than the maximum possible size, and then the target moves out of that space, they don't grow further once there is more room — the growth at the beginning of the spell is all you get, nothing more later.
So, the conclusion there is that the druid can shapechange into a form, and the enlarge effect is not applied to the new form. If they change into a sparrow or a bear, they get the normal statistics of a normal sparrow or normal bear.
That means that a druid that wants to dodge an inconvenient enlarge or reduce can easily do so by wild-shaping, but a druid that wants to benefit from enlarge or reduce in their wild-shaped form will have to somehow arrange for the spell to be cast after they wild-shape, so that it will grow their new form instead of just their previous form.
Best Answer
It sticks to the druid and applies in every form.
The other answer you cite argues thusly:
This reasoning is wrong. The Wild Shape rule is this:
So, when you revert, you return to the number of hit points you had before you transformed--any damage does not "carry over to your normal form" except in the case where the beast form dropped to zero. But the maximum hit point reduction is a separate effect from damage, and Wild Shape doesn't say that effects in general don't carry over between forms.
Who or what is the target? The druid. Therefore the druid's maximum HP will be reduced until the druid finishes a long rest. This applies to every form. When the druid takes on a form, you look up the hit points it will have in that form, and then subtract whatever reduction it's suffering to its maximum HP.
So in this example where the bear loses 24 max HP, in step 3 the druid should be at their new maximum of 21.