Yes, dogs can often sense when their owner is unhappy. They read body language, facial expressions, and tone of voice. They can also detect scent changes from stress hormones and notice behavior changes such as withdrawal or reduced activity.
Dogs may respond with comforting behavior, attempts to distract you, or withdrawal of their own. Sensitivity varies by dog, but many are emotionally attuned to their owners.