We know that he can only say his name. I observed from the series that whenever he is spoken to, he replies with:
Is this how he was named? Or did someone give him Hodor as a name and then he replied:
Science Fiction & Fantasy Stack Exchange is a question and answer site for science fiction and fantasy enthusiasts. It only takes a minute to sign up.Sign up to join this community
We already knew that his real name wasn't Hodor, but Walder (books) and Wylis (TV Show). We learn the origin of "Hodor" in the 5th episode of the 6th season.
SPOILERS FOR S06E05:
We see that when Meera, Hodor and Bran are trying to exit the cave in order to escape the Night King and his army, Meera is carrying Bran on the sledge and tells Hodor to "Hold the Door" over and over, in order to prevent the White Walkers from exiting the cave and catching up to them.
While this is happening, Bran is viewing the past and inadvertently warged into Wylis (Hodor's real name), thus linking the present day Hodor with young Wylis. Hodor then has a fit and falls to the ground, while shouting "Hold the door" repeatedly. He gradually removes some words (Hold the door -> Hold door -> Hodor) and that is how he started saying Hodor.
There is also an 'Inside the Episode':
Where David Benioff says that this is in fact the same origin for the name as in the books.