How does the shield of a coaxial cable work?
My question is: how does the shield operate in order to get 0 (or near
0) electromagnetic field outside the cable)?

The external magnetic field generated by the returning current in the shield is exactly cancelled by the opposite external magnetic field due to forward current in the inner (or core).
There will be a magnetic field between shield and inner (core) though.

I've previously done this task using QuickField to show the magnetic fields in two scenarios. The coloured contours show flux density B: -

The models are a little crude because this is the student edition of QuickField and it doesn't give you many free finite element nodes to play with hence, the model is a tad clunky, restricted in boundaries but, delivers the goods for this question.
The first scenario shows the magnetic field surrounding the shield when 1000 amps exclusively flows through it at 100 kHz. Notice that there is no flux produced inside a current tube (as per classical physics) but there is still induction to the inner core (96.3 volts)
The bottom scenario is the same applied current but exclusively flowing in the inner. Notice that is produces flux all around the inner core and, if you look in the boundary corners at the colour change, it is the same in both scenarios thus implying flux density is the same.
The decisive number - the voltage across the shield (per metre) in scenario 1 is 95.9 volts and, in scenario 2, the voltage across the shield (due to induction from the inner) iis 96.4 volts (per metre). In a perfect world, with a perfect model, with infinite boundaries, those two voltages would be the same thus indicating that: -
$$\color{red}{\boxed{\text{The external fluxes are the same but opposite for opposing currents}}}$$