It's established that the Sorting Hat and the Student communicate, and that the Sorting Hat is able to see into the mind of the user, hence why he is responsible for sorting the students into the four houses.
It's also established that Polyjuice potion only alters the the user's appearance. Its voice thoughts and desires are independent of the Potion's Target.
Now, for the sake of this question, let's assume we have a really nasty Ravenclaw that is his team's Quidditch captain. There's a new kid going into Hogwarts that is a known prodigy in flying, and thus the Ravenclaw captain would love to have him on his house so he can win the House Cup. The thing is, this student is really dumb, but very kind. Everyone assumes he's going to go into Hufflepuff (whether or not this is true isn't known obviously). The Ravenclaw's team captain decides that he wants to make sure this student (Let's call the new student Logan for the sake of reading) a sure-fire entrance on his House. So he conducts the following plan:
- Sneaks into the boat shack
- Lures the student away from the pack and knocks him out
- Turns into the student using Polyjuice potion and acts like him
The sorting ceremony would begin as usual, and Logan would be summoned, and the Ravenclaw Captain would place the Hat on his head.
Would the sorting hat know that he isn't on top of Logan? (meaning that the plan would've succeeded) If so, would the hat call out the imposter or keep silent?
This question should be broke down into the following:
- Is the Sorting Hat Omniscient? Does he know who everyone is?
- Is the Sorting Hat using Legilimency to sort Houses (thus he could discover the plot)?
- If #2 is Yes, would a skilled Occlumens be able to fool him?
- Is there any known protection against Student Posers? (Barty Crouch Jr. posed as a teacher)
- Can the Sorting Hat be fooled?