When you put your dog in his crate or in a gated room, turn your back and ignore him.
Once he stops barking, turn around, praise him, and give him a treat.
As he catches on that being quiet gets him a treat, lengthen the amount of time he must remain quiet before being rewarded.