Limiting the total number of visits to a particular state in Markov chain

I have a initial two state transition probability matrix, say A = [0.5 0.5; 0.7 0.3]. I want to create a Markov chain with 10 steps. In which I want that the chain should not have more than 40 % of state 1 and the remaining 60% to be in state 2.

For example: I want a Markov chain like this: 1 1 2 2 1 1. As state 1 has occurred 40% of the time so now it should not occur in the chain and the remaining chain should be like 2 2 2 2. That is, the final chain should, for this simulation, looks like 1 1 2 2 1 1 2 2 2 2.

Any solution even near to imposing the global limitations is also acceptable.

Let's label your initial states $1$ and $2$. You can introduce new set of states such as $(1,z)$ and $(2,z)$ where $z$ is the number of visits in state $1$. The transition probabilities change accordingly: $$P(x_{t+1}=(1,z+1)|x_{t}=(1,z)) = 50\%$$ and $$P(x_{t+1}=(2,z)|x_{t}=(1,z)) = 50\%$$ Similarly: $$P(x_{t+1}=(1,z+1)|x_{t}=(2,z)) = 70\%$$ and $$P(x_{t+1}=(2,z)|x_{t}=(2,z)) = 30\%$$ These transitions are defined for $z\leq4$. Then it turns into $$P(x_{t+1}=(2,4)) = 100\%$$ All other transitions (not mentioned above) are zero.
The initial state is e.g. $(1,0)$.