Just introduce extra states. The total description of a state will include the length of the queue and the stage of service for the current customer. For instance, if each initial service may result in the second stage service with probability $q$ and the departure rate for this second stage service is $\sigma$, then you'll get 2 equations corresponding to 2 possible states with queue length $n$: $\mu p_n(1)+\lambda p_n(1)-\mu p_{n+1}(1)(1-q)-\sigma p_{n+1}(2)-\lambda p_{n-1}(1)=0$ and $\sigma p_n(2)+\lambda p_n(2)-\mu p_{n+1}(1)q-\lambda p_{n-1}(2)=0$ (Just look at how you can depart from the state and put the corresponding terms with plus and then look at how you can arrive to the state and put the corresponding terms with minus. For instance, the terms in the first equation correspond to having been served at stage 1, new arrival to the queue serving a stage 1 customer, completely finishing serving a stage 1 customer in a queue with $n+1$ customers, finishing serving a stage 2 customer in that queue, and arrival of a new customer to the queue of length $n-1$ serving a stage 1 customer). Sometimes you can simplify resulting big systems to smaller ones but the general idea is always to start with the set of states that fully describes everything that may happen in the system, not just the parameters you want in the end.