I finally decided to sit down today and figure this issue out. This is an old bug, I had the exact same problem with Marshmallow and my Nexus 6P. It is related to Do Not Disturb.
So here's what I did to fix it. I sent a text to my phone and no sound came. Rebooted, sent another text and it made a sound. Sent another text, no sound, several more texts - no sound.
I remember making a monthly meeting in my calendar that would DND my phone for an hour during the meeting. But I had removed the DND thinking that was the issue. So I decided to delete the monthly meeting from my calendar. Guess what??? Sent a text and I got a sound!!! Sent another one, got a sound, sent a few more and now it works perfectly.
So somehow there is kink with Google Calendar and DND's. It could be with DND's that were created with prior versions of Android.
I just had a feeling this was the issue after reading how many would factory reset their phone and the bug would come back. Once it brings in your calendar data it's hosed. I hope this helps. It was a really annoying bug.