How should I communicate that I do not hold the views expressed in a paper I wrote
I would precede my paper by a strong explanatory note disassociating myself from the views expressed in the paper, in boldface and surrounded by a big black frame. For extra clarity and safety, I would then quote verbatim the assignment that the project is fulfilling, before starting the actual paper. E.g.:


  Confessions of a cannibal
  Final project for Philosophy 101
  [your name]
  
  Explanatory note: the views in the essay below are written in the context of a final project assignment for the course Philosophy 101. They are fictional and do not represent the author's actual views on cannibalism or on any other subject.
  
  Project assignment: "Write a 4000-word essay written from the point of view of a cannibal living in New York City in the year 1987. Discuss the narrator's views and opinions on cannibalism and other topics of interest."
  
  [body of the essay]


I should note that you say "To an external observer it may not be clear that I am not allowed to disagree with the premise of the prompt." It's not clear to me if you mean that you are not allowed to include an explanatory note of this type, or even to quote the assignment text. If that's what you meant, I'd have to say that forbidding you from including such explanatory text would in my opinion be tantamount to requiring you to actually pretend to be a cannibal (or other such person with unsavory views), which would be a highly unethical requirement. In the face of such a restriction, I would frankly refuse to hand in such an assignment, and take the matter up with the instructor and/or higher university authorities.