There is a little bit of truth in this. When burglars case a house, they might choose to leave a house with a barking dog alone all else equal. That said it won't stop a determined burglar or home invader, but it can dissuade a casual intruder.
My childhood dog barked liked crazy at anyone who entered our driveway and some of my classmates said he was scary. But as soon as they got inside, he'd stop barking and start wagging. One friend joked that the translation for his barks was "COME INSIDE! COME INSIDE! COME INSIDE!"