How to share ground connection between to microcontrollers connected to a PC
This is fine, you only get a ground loop when grounds are not at the same potential. You do need to connect both grounds, but as you're using USB connections from the same PC, you potentially (see below) don't need any further wiring.

As pointed out in the comments, there is potential for noise to cause differing ground potentials and hence spurious/corrupted signals. So, best practice would be to include the wire (as you've drawn) so both microcontroller grounds are connected by a low impedance connection.