Yes, they can. Dogs and cats detect differences in mood, behavior, and body chemistry that tells them of an oncoming change. They also can sense other signs such as body language and changes in your daily routine too.
Dogs are more involved than cats. They are more alert and go on a protective mode from the early beginnings of a pregnancy. They may growl, bark, or even block entrances with their body. Sometimes they may even go one step further and prevent even the father entering the room of the expected mother.
Cat’s behavior may not be highly visible as a dog. Reports indicate that cats may get more loving or become uninterested. However, if you neglect the cat they tend to become more aggressive and may even urinate where they are not supposed to do so.
So be careful not to neglect your pets during a pregnancy. Do things with them as you used to do with them such as walk your dog. If you are unable to do that make arrangements for someone else to do it for you. Also you need to prepare your pets for the arrival of the baby. Do not neglect your pets and get them involved while raising a new baby.