In the first case, under US law, you are not considered guilty in most cases where you are forced to commit a crime under duress (gun to your head would certainly qualify). Murder is a rare exception to this rule, and the patron can be tried for the murder of the prostitute. Given the nature of Doe, who uses situations of duress to force a no win scenario for his victims, a good defense would likely work to get Jury Nullification of this crime, given the circumstance. The likely defense would be to validate that the man would not ordinarily kill a prostitute and thus only under a situation such as the one presented would he. It is still a crime, but the jury could choose not to convict, but it's a gamble as the law of crime of duress is likely to come up in the course of the trial.
Situation 2 is a little more grim, as in this case, Doe has already surrendered and is custody and admits to a crime that is personal to the detective. I haven't seen the movie, so I can't suggest if there was an appropriate time for MillerMills to be pulled from the case prior to this revelation, but if such an opportunity happened, he should have. Since Doe is not threatening MillerMills at the point of time and he had already carried out his crime and been captured, MillerMills is an officer of the law who is killing someone in his custody. This is a crime and should be prosecuted. The circumstances might serve as mitigating factors and the jury may nullify, but these are circumstances that are less likely than the above case. Miller Mills is also the lead detective in this case (?), and thus should know how Doe functions and what he is trying to get done.
In the role of prosecutor, I personally would not push the crime against the patron as the likely jury would be too sympathetic to the defense. I would prosecute MillerMills as his responsibilities as a law enforcer and his training would have made him well aware that what he did was a crime.