How to change file ownership when chown says "invalid user: ‘–R'"?

You must have copied the command from a webpage that uses strange formatting. That's not a normal minus, try this instead:

sudo chown -R hduser:hadoop mongodbdata

Specifically, the one I copied from your question is an en dash (U+2013):

$ unicode -s  –
U+2013 EN DASH
UTF-8: e2 80 93  UTF-16BE: 2013  Decimal: –
–
Category: Pd (Punctuation, Dash)
Bidi: ON (Other Neutrals)