Kind of like asking "how do ants build their mounds to defend against ant-eaters".
I think you'd have to nail down limitations on how your dragon could behave to answer this one - and how the neighbors behave as well.
If your dragon can't hover in one spot, a spiky pyramid type shape may work - as landing on it would get the dragon impaled. Underground forts or forts built into the bottom of mountain cliffs may rob dragons of the ability to fly over the fort. Being far, far away from anywhere a dragon might nest could help :p.
If your dragons can but don't like to walk too far, putting far extended roofs over everything might help as they unlikely to be able to torch anything valuable without landing - and the rooves would likely collapse beneath them if they tried landing on them.
Rock is less flammable then wood last I checked as well, so remove as many of the wood bits from the important architecture as possible.
I think knowing whether things besides dragons are going to attack would also effect castle priorities. If one expects regular armies to attack you occasionally as well you going to get pretty normal looking forts - as the normal castle needs to cater for everything, even if the base design isn't the optimal plan for flying death lizards. If dragons are the only thing that may attack you I think you'd get the opposite of a fort - namely individual homes with underground bunkers which are all in range of raised artillery platforms - as dragons are far easier to hit once they land to try snack on something.
Seriously though, when a creature is designed as flying yet heavily armored, massive but fairly nimble and capable of both melee and ranged attacks (and probably intelligent), there is no easy counter save for existing in a place to small for the giant death beast to fit into - which isn't an option above ground. The only mythical beast which would be harder to defend against then dragons would be giant tunneling wurms -.-