This is very difficult for a number of reasons:
1. We see clearly from Rashi that Moshe knew that the Meraglim would sin, that is why he davened that Yehoshua would not be caught up in it. If so, why did he send them at all? After all Rashi comments שלח לך that Hashem gave Moshe the choice as to whether to send meraglim or not. If he knew they would sin why didn't he just cancel the mission?
2. Why daven only for Yehoshua? Yehoshua was probably the greatest of the meraglim, why would Moshe worry that he would sin? At the time that they were picked all of the Meraglim were tzadikim, why didn't Moshe daven for all of them?
3. How can Moshe daven that Yehoshua should not sin? Even if you come up with a theory of how prayer works for someone else, it still doesn't explain how Moshe can pray for Yehoshua not to sin, after all הכל בידי שמים חוץ מיראת שמים, so whether a person sins or not should be solely in his hands and not be able to be affected by anyone else.