If you are in a clan, and other members of your clan donate troops to you, they will be stored in your clan castle and come out for defense. This is the only way that I know of to defend with troops. So no, you can't train troops and use them for defense. However, others may donate troops that you can use for defense. Also, skeleton traps may be considered troops by some, even though they are not trained.