As others have noted, it is possible. If this is something that you are looking to do, I have two recommendations as it can be a complicated process:
1. Make sure that your lender is aware, and that they can actually do the loan. Underwriting can have strigent standards.
2. You want your Realtor(R) to be experienced in similar types of scenarios, or the same one. I personally wouldn't feel comfortable with this type of transaction, as my specialties lie elsewhere.
Personally, I would just buy the duplex and rent the other side out, but that is just my own personal opinion.