With a recent tandem purchase, I have been faced with that choice when my 10yo was riding stoker. Even with him on the bike, if the situation calls for me to put myself into a position to obstruct the lane to prevent a bad/unsafe pass, I do it. I am also scouting out a backup plan if the vehicle driver attempts to pass anyway.
It's never cut and dry though. When I educate my 3 kids on bicycle safety, I stress that the best way to stay safe around vehicles is to avoid them altogether. Watch for pinch points, don't put yourself into a tricky situation and use your best judgement. I also tell them to listen to see if the driver has lifted from the throttle, what speed the vehicle is going in relation to the conditions (blind curve, hill, oncoming traffic), etc... and to never trust that anyone has seen you and even cares to be cautious if they do see you.