The trick is that a person acting on behalf of the municipality is not legally a person, they are an “officer” - a proxy of the city. But it is not as straightforward as this. Can it be demonstrated that they were engaged in actual municipal business? (they will always say “yes”) And does the resident have any reliable evidence that they are really an officer, on town business? The resident would have case for their defense with these factors, but it would certainly not be easy.
As an example, I had a cop in Boston threaten to kill me because I confronted him over a traffic accident I saw him cause. When I went to his precinct to file a complaint against him, they refused to take my complaint saying that I must have been mistaken, because A Police Officer would never possibly do that! So were they factually disavowing that the guy was really a cop? Yes, they more or less did! Does that mean that I’d be within my rights to kill him if he threatened me again? Yes, it arguably might! Would the PD just let it go? Hell no! They would almost certainly change their story in an instant. They were running their mouths to take a little heat off, betting that I was not going to act upon it.
I could give other examples. I worked on the streets in the Boston/Cambridge area for years, so had many encounters with police. A few of the respectful, but mostly not. How I handle them is to cooperate, but make everything symmetrical. IE I have a high burden of proof for them. I demand proof of their indentities, to talk to their supervisor, to document who their dispatcher is, demand proof of whose car and sidearm they have, etc. I am completely cooperating - on the condition that I can verify that they are actually officers, engaged in legitimate activity. They get hot about this. I have had cops threaten me with jail and death over it. If they stop me, we will be there for hours. I will not let them leave unless they prove that they are legit.
You cannot afford to be the slightest bit intimidated. It is like confronting a wolf or mountain lion, if they sense fear, they will attack you. But you need to be polite also! My demeanor is that of grave concern, like I caught a little kid getting into trouble. And don’t even think about standing up to them like that if you were actually in the wrong about something.