Whenever Etrata deals combat damage to a player, exile target creature that player controls and put a hit counter on that card. That player loses the game if they own three or more exiled cards with hit counters on them. Etrata's owner shuffles Etrata into their library.
If the player controls no creatures, Etrata’s ability doesn’t resolve. Etrata remains on the battlefield and its owner doesn’t shuffle their library. The same is true if the target creature is an illegal target when Etrata’s ability tries to resolve.
If Etrata leaves the battlefield while its triggered ability is on the stack, it remains in its new zone and Etrata’s owner shuffles their library.
If Etrata’s ability exiles a token creature, it won’t count to determine whether three cards are exiled with hit counters.
Etrata’s owner shuffles it into their library as the triggered ability resolves, regardless of how many cards are in exile or whether the player loses the game.
In a Commander game, if Etrata is your commander, you may put it into the command zone as its ability resolves. You’ll still shuffle your library.