Me too I didn't suspect that was even possible. If it's not a hack maybe PWA are not that far from mainstream.
Google is the unique bright light here. They've submitted a web standard, navigator.mediaSession [0], that lets you do this in a web standard way. Unfortunatly, the only browser that implements it is Chrome on Android.
[0]: https://developer.mozilla.org/en-US/docs/Web/API/Media_Sessi...