You can teach your dog to bark on command even if you don't expect it to actually protect you. If you want to use the "guard" command instead of something more benign like "speak", that would probably be enough of a deterrent for most people.
I was thinking along these lines - barking that's just a behavior, like any other behavior, without any emotions behind it.The dog doesn't need to know why you are teaching it to bark on command.