Apple - OSX Mail how to mark message as not junk
It seems iCloud is marking the message as junk using its algorithm. I don't believe you can adjust this from within the Mail.app. You will need to log into iCloud.com, enter Mail, find the particular message in your Junk Mail folder and then with the message selected, select the gear menu and you should be able to Mark as Not Junk.
To recap, as iCloud is flagging message as junk you must unflag message within iCloud.
There isn't a tie between the server filtering of junk mail and the Mail client on the mac.
If this is troublesome, most people pick to disable the server side filtering and train the Mail client on their mac so that it can do all the marking and filing so you don't have this cognitive dissonance between a message that your local mail client "thinks is junk" and mail that sits in a folder that coincidentally is named junk.