The defensive player is committing a foul in the situation described. I am drawing here from the NBA rules, but high school and NCAA are essentially the same.
Section I—Types
A player shall not hold, push, charge into, impede the progress of an
opponent by extending a hand, arm, leg or knee or by bending the body
into a position that is not normal. Contact that results in the
re-routing of an opponent is a foul which must be called immediately.
Contact initiated by the defensive player guarding a player with the
ball is not legal. This contact includes, but is not limited to,
forearm, hands, or body check.
EXCEPTIONS: A defender may apply
contact with a forearm to an offensive player with the ball who has
his back to the basket below the free throw line extended outside the
Lower Defensive Box. A defender may apply contact with a forearm
and/or one hand with a bent elbow to an offensive player in a post-up
position with the ball in the Lower Defensive Box. Incidental contact
with the hand against an offensive player shall be ignored if it does
not affect the player’s speed, quickness, balance and/or rhythm.
By this description, hugging is certainly a position which is not normal. This is confirmed by the listed exceptions; i.e. those times when a defender's arm is allowed to make contact with an offensive player. "Hugging" is not listed as an exception. The rule clearly establishes the offensive player's freedom of movement as defining the foul. "Hugging" or "enveloping" is, therefore, clearly a foul.
https://official.nba.com/rule-no-12-fouls-and-penalties/