Yes, you use triggers to create a random unit type at the position of the building.
Or you make the building hire the units and use triggers to change what is available to hire to random unit types from an array.
If you mean actually build units, you could have multiple of the same building type (each with different units available to build) and randomly choose one once the building is built.