Preservation of context-free languages under prefix and suffix elimination
I answer for the case that an arbitrary number of leading or trailing $0$ can be deleted. This supposes that your $L=0M0$ is wrong; it would mean that all words in $L$ start and end with $0$. Since the rest of your question does ot seem to imply this and since that case would be rather trivial, I ignore this equation and answer what I understand from the rest of the question.

You are right. There is no bound on the number of 0 in the beginning, and each one of them can put something on the stack. Thus there is an infinite number of possible stack configurations that can be reached after reading them. 

My idea is this: essentially we replace the transitions that read $0$ by ones that read the empty string $\lambda$. The problems are now that $0$ inside $M$ must still be read and that the $\lambda$-transitions could be executed inside $M$, too.

Therefore we make three copies of the sets of states and transitions. In the first one we replace input $0$s  by $\lambda$ in all transitions. All transitions reading an input different from $0$ lead to the corresponding state in the second copy of the state set. 

The second set works like the original PDA reading the word from $M$. For every transition that reads $0$ we add a copy that leads to the corresponding state in the third set; these amount to guesses that the current $0$ starts a final block of only $0$.

The third set works much like the first (reading $\lambda$ instead of $0$), only for inputs other than $0$ it rejects.

For the $L=0M0$ case you can adapt this contruction as follows: all the new $\lambda$-transitions from the first set lead immediately to states of the second set. In this way only one leading $0$ is simulated. For the termination: go to a special final state after simulating the read of one $0$.