The first part of the Gelatinous Cube’s Engulf reads:
Engulf. The cube moves up to its speed. While doing so, it can enter Large or smaller creatures' spaces. Whenever the cube enters a creature's space, the creature must make a DC 12 Dexterity saving throw. On a successful save, the creature can choose to be pushed 5 feet back or to the side of the cube. A creature that chooses not to be pushed suffers the consequences of a failed saving throw.
The first benefit of sentinel reads:
Whenever you hit a creature with an opportunity attack, its speed drops to 0 for the rest of the turn. This stops any movement they may have been taking.
Now, normally, a player character cannot make an opportunity attack against an engulfing cube: The normal 5 feet attack reach means they must be in the engulf line; if they fail the saving throw, they’re engulfed; otherwise they are pushed out of the attack reach.
However, using a long weapon (10 feet reach) means that they can potentially get an attack of opportunity without ever being in the line, or after the character has been pushed.
Making a successful opportunity attack will definitely drop the cube’s speed to zero. I am also pretty sure that engulfing counts as willingly moving out of reach (correct me if this assumption is wrong), however, will sentinel stop the engulfing? The wording of sentinel seems to imply there be a connection between the speed reduction and stopping movement being taken and I am unsure if engulf counts for this.
Clarification:I am asking about the general possibility of stopping the cube, not specifically to avoid being engulfed. It seems however, that if stopping the cube like this works, that polearm master would make it possible to avoid being engulfed.