I currently use an crufty old app from F-droid which overrides the screen orientation using an invisible overlay (I believe) and that works rather well. However, when returning to a forced landscape app from the lockscreen (which is in landscape), android rotates the screen to portrait which I don't want.
I use Spotify and it believes that it knows better than me how I'd like to use my phone and wants to display its playback control screen portrait mode. I obviously need to return to this screen often to change tracks etc.
Is there a better way of doing this? I imagine you'd need something integrated into the SystemUI to get the unlock transition smooth.
I'm not afraid of getting my hands a little dirty with Magisk modules or patches to AOSP components themselves (I build my system from source) but I don't think I'm in a position to be coding something like that myself yet.