Hi Rémi,
Thanks for the question. I don't think I'm totally grasping what you want to do, but let me give it a try.
The short answer is that the formal dimension of the model can't change during MCMC. What can change is the parts of the model that are actually used, such that formally the dimension is constant but in practice some parts are not always used. Often this is controlled with some kind of indicator variable scheme, with variables that are 0 or 1 and multiply other parts of the model such that a "0" has the effect of "turning off" part of the model.
If the misidentification you are talking about is misclassification of the state of an individual, with the individual correctly identified, that can be handled by a Hidden Markov Model. The vignette to nimbleEcology can help one get started on that.
But I think what you are talking about is if individual A might have been recorded as individual B. In that case, I think what you are talking about is for example a capture history with (unknown) misidentification, say (1, 0, 1), might really correspond to two correct capture histories, (1, 0, 0) and (0, 0, 1), and so on. I am not sure off the top of my head if there is a very clever way to implement this purely in the model language and have the MCMC sampling work out ok. If you can write it formally as a distribution, you should be able to write that distribution as a nimbleFunction, I hope.
Another option is I think you could implement this with a custom MCMC sampler to make propose-accept-reject (Metropolis-Hastings) steps of which identification goes with which individual, while respecting the constraint that one observation can belong to one and only one individual at a time in the chain. This may need to involve a data augmentation scheme for never-observed individuals. So, I think it would be non-trivial but could be done.
I hope that helps. If I've missed the boat, please follow up.
-Perry