Recently I was issued a device with a work profile installed. (A Samsung Xcover6 Pro, if that helps). During initial setup, I was prompted to configure some of the extra hardware buttons inside the work profile, and doing so opened the settings app inside the work profile.
I later changed my mind about what setting I had made, but due to a bad decision by either my employer or Samsung, the settings app is not available inside the work profile. Dishonorable mention goes to Samsung for having the physical hardware buttons do different things when I have a work app open than when I have a personal app open and no way to configure both scenarios.
Initially, I thought this could be done with adb shell am start -a android.settings.SETTINGS --user 10
, however that just launched settings as the default user and displayed the message "You're using this app outside of your work profile."
Eventually, I discovered that I had to specifically specify a compatible page to directly open that page. For example, for whatever reason I cannot access display settings, but the settings page for the xcover key could be accessed. An imperfect solution, but it solved my immediate need of remapping the key as desired. For the record, the adb command I ended up using was:
adb shell am start --user 10 -n 'com.android.settings/.Settings\$UsefulFeatureMainActivity'
Which on a Samsung device with an extra hardware key should allow you to remap those keys when the work profile is open. If anybody has a more generalized way to open the whole settings app as the work profile user (or, I suppose, any user profile enabled on your device), I'd love to hear it. Bonus points if it's something that could be configured to run without being connected via adb.