From Scientific American, an empirical study of this perennial question. About 3/4 of dog owners believe that their pet can feel guilty and can act guilty.
Go read the whole article--because they describe some experiments used to test this guilty dog hypothesis--and it may not be as clear cut as it seems:
Given that so many dog owners report that they believe that dogs who have broken a rule act guilty even before the dog’s transgression is discovered, and given that owners report that they are likely to scold their dogs less following the display of guilty behaviors, it stands to reason that dogs’ “guilty look” may just be a learned response. If scolded, a guilty look might simply serve to reduce the duration of the negative social interaction.
The problem is that the display of the associated behaviors of guilt are not, themselves, evidence of the capacity to emotionally experience guilt. Do guilty behaviors follow from transgressions? If so, that would provide evidence that dogs may be aware of the violation. Or do guilty behaviors instead follow from scolding? This is a reasonable speculation, given that owners tend to scold their dogs less if their dogs “act guilty.” If this was the case, guilty behaviors could simply be the result of a learned association between a stimulus (such as crap on the carpet) and impending punishment – not so different from Clever Hans, the famous horse who relied on subtle behavioral clues from his owner in order to “succeed” at mental arithmetic problems. This is an empirical question that can be answered with a clever enough experiment.
The researchers do provide a soft conclusion:
Taken together, these results both support the common anecdote, that dogs act guilty prior to their owners’ awareness of the violation, as well as the earlier scientific findings that, regardless of transgression, dogs act guilty in response to being scolded by their owners.
But with a big caveat...
Future research, according to the researchers, ought to investigate these questions in a familiar environment rather than in a laboratory, and should examine a social rule that has already been established between an owner and a dog. It may still be some time before we can know for certain whether dogs can experience guilt, or whether people can determine if a dog has violated a rule prior to finding concrete evidence of it.