Create a unit named "Max 3"
set this unit as the requirement for the building you want to limit to 3.
On map init, create this unit for the player.
Then have a trigger that checks when the player builds the building, when >= 3, kill the unit.
Then have a trigger for when the player loses the building, then create the unit again.
The condition you seek is "Unittype of triggering unit equal to Building of Awesomeness".