Is it possible to have IOR change based on how many layers the light ray passes through?

Yes - this can be done (see my thread below) - however it does have limitations.