Is it possible to change automationName capability dynamically within a single test script?

I’m working with an Android device and the app I’m trying to interact with doesn’t behave in an expected manner all the time. Some features of the app can only be interacted with when I use UiAutomator2 as my automationName and others can be interacted with only when Appium is the automationName. I’m not quite sure what the reason for this could be. I’m wondering if it’s possible to change the automationName capability dynamically whenever I need to use UiAutomator2 or Appium.