Axis - Tick Format Function

I have a series of numbers in my Y Axis. For numbers less than or equal to 3000, I want to format them as “a” + value. For numbers greater than 3000, I want to format them as “b” + value.

So, in the screenshot here, I would like the ticks to be “A2000”, “A3000”, “B4000”, “B5000”, “B6000”, “B7000”.

I cannot use tickvals and ticktext because I want Plotly to decide on the ticks based on the range of values. When I define the tickvals and ticktext, I end up in situations where the tick labels overlap.

Is there a way to define a function like this and have Plotly use it to render the tick text?:

def format_my_y_tick(v):
  if v <= 3000:
    return f'A{v}'
  return f'B{v}'

Thanks!