It is possible to claim duchies. The most straightforward (although not necessarily speedy) way is to send your chancellor to fabricate claims. Most of the time he will get a claim on a county, but there is a small probability that he will obtain a claim for the whole duchy. This option should always work, but it takes a while (unless you are Catholic and your target is the pope). Sometimes you will also get plots to fabricate a claim. I find that these usually work quite well.
Another, potentially a lot more complicated way is to find a claimant to one of the duchies who are either your vassals or of your dynasty and pressing their claims. If they are not of your dynasty or your vassal, the duchy will not join your realm after the war (although the claimant still gets the title). If the current duke is adult male, they need a strong claim, otherwise a weak claim works as well.
You can get a list of claimants by clicking on the coat of arms of the duchy you want (or a county in that duchy and then navigating to the duchy by clicking on the CoAs at the top of that screen), then clicking on the claimants button. All of those with a green thumbs up will accept an invitation to your court. If you are lucky enough that they are of your dynasty and have a strong claim you are all set. Invite them to court and press their claim.
However, most of the time you will not be so lucky. If they are not of your dynasty then give them a title somewhere in your kingdom - this will make them your vassal. If their claim is heritable and you don't want to give them a county inside your realm you can also marry them (matrilineally if they are male) to a member of your dynasty. Their kids will then have a claim and be of your dynasty.
Finally, you need to check if their claim is weak or strong. If weak, then arrange for the duke to be either female or a child. This can be done through assassination.
If none of the above options work, then take one of the counties in a larger duchy that will allow you to usurp the duchy title (you need over 1/2 of the holdings in the duchy).
Also, if you are loosing claims to duchies, this could be for a number of reasons. Firstly, it could be that last time you went to war the weak claims were applicable (ie. some of the relevant duchies may have had female or child rulers). If the claims you had last time were fabricated by the chancellor, note that they are not heritable. However, non-heritable claims become heritable if you press them in a war (even if you loose the war).
(As an aside, once you are an emperor you can vassalise the pope. This is great.)