You can replicate this by placing boats around you. Mobs like Endermen, Piglins, etc, all get pulled into a one whenever treading nearby. This would be pretty funny actually, if it didn't afterwards trivialize combat because your foe is completely passified!
Hostile mobs should be unable to get into boats when aggroed and following a player. For instance, trapping Wardens with boats would be the quickest way to kill the vibe of the mob you're trying to sell.