That's exactly what it's for. Yes, you can limit to certain contacts or those in your phone app's favorites. Set it in Settings > Do Not Disturb > Allow Calls From > set to your liking.
You would need to set up a contact group if those were the only ones in contacts.
I have groups set up as seen in the pic. But I set it on favorites.
I used this app to set up my groups. Most do it on a computer. But I figured how with this app.
SA Contacts - Export/Import contacts to/from Excel by Sam Yu
https://appsto.re/us/hwXMw.i