I do not know if native android 9 supports touch on external monitor. It might be a Samsung DeX feature? Or as you suggest Android 12.
Maybe LineageOS or AICP? At the least they are offered based on newer android than 9/pie.
ADD
It seems to have been in Android for a decade, BUT needed/needs a proper driver....
See e.g. https://forum.xda-developers.com/t/connecting-android-tablet-to-external-touch-screen.1294268/