Do you mean add a new unit that can be trained into the barracks? Do you want the unit greyed out until you get some new structure or do you want it to just appear?
I think you can do this by adding all the units to the structure and then disable them at the start (makes them not appear) and then enable them when the player gets something needed for the particular unit.
With the greyed out units, you can make them have a tech requirement and make the requirement the unit or building or upgrade you want to be required for it.