Yes, by using Partitions and Calling Search Spaces.
Here is a basic example that you will have to modify to suit your needs:
1) Create two partitions, Site_A and Site_B
2) Create two calling search spaces, CSS_Site_A and CSS_Site_B
3) Add Site_A partition to the CSS_Site_A CSS and Site_B to the CSS_Site_B CSS
4) Assign the Site_A partition and CSS_Site_A CSS to the directory numbers (or physical phones) for Site A
5) Assign the Site_B partition and CSS_Site_B CSS to the directory numbers (or physical phones) for Site B
With this configuration, Site A phones will not be able to call Site B phones. If you have any numbers that you want both sites to be able to call, create another partition (All_Sites) and assign those numbers, devices, route patterns, translation patterns, etc to that partition. Then add that partition to both the CSS_Site_A and the CSS_Site_B CSS's.