Late in the game here, but confirmed on an iPhone 7 Plus (11.4.1). Doesn't matter what audio-based app is running (including Phone, using a headset), or whether wired headphones (either Apple-provided Lightning earbuds or using the 3.5mm adapter) or Bluetooth headphones, audio will silence and/or garble once the lockscreen becomes active.
However, after a couple of months of carefully observing this (rather than continuing to curse about it), it seems that this glitch surfaces when audio is played with the lockscreen engaged following the removal of supplied power through the Lightning port.
In other words - phone had been charging, now disconnected from charger, audio plays, lockscreen engages (either manually or through a screen display timeout)... audio glitch follows. After the 15-45 seconds (average) of silence when the BT headphones receive the audio again, or when wired headphones' audio becomes garbled (an unlock with a manual pause and play sometimes fixes, otherwise disconnect and reconnect headphones), the glitch becomes much less frequent. (I didn't say "nonexistent"; it has reappeared... but less prevalent under 11.4.1 compared to earlier updates)
Once connected to power again, the glitch will come back the next time audio plays through the lockscreen after the device is disconnected.
If trying to listen (using BT headphones) while simultaneously charging (e.g. while on a phone call), the glitch will occur repetitively.
What makes this strange is the fact that if this is indeed a software issue (involving the OS's interaction with the Lightning port), why are devices which still have the 3.5mm headphone jack (iPhone 6/6S) experiencing this?
My iPod Touch 6G (which has 3.5mm jack) is also on 11.4.1 - not a sign of this issue whatsoever, neither with wired nor wireless headphones.