Fortunato does not realize that Montresor plans to harm him until he has had a little time to sober up. It would appear that he begins to realize the terrible situation he is in at the following point in the story.
I had scarcely laid the first tier of the masonry when I discovered that the intoxication of Fortunato had in a great measure worn off. The earliest indication I had of this was a low moaning cry from the depth of the recess. It was not the cry of a drunken man.
Fortunato has to go over a whole series of incidents in his mind. He met Montresor up on the street. Montresor said he had a pipe of Amontillado he needed to have an expert sample. They came back to Montresor's palazzo together, down the stairs, along some passages--and now he is chained to the granite wall of a narrow niche, and Montresor, whom he thought was his friend, is starting to build a wall. The "low moaning cry" must represent Fortunato's realization that he has been tricked. Montresor has been deceiving him for years and has made a fool of him.
There was then a long and obstinate silence.
Fortunato, now fully sober, must be feeling the chains, the padlock, and the bolts holding the chains to the rock wall. He is hoping to find a weak spot of some sort. But he wouldn't want to break free as long as Montresor was still there. Montresor might kill him. He is thinking of waiting until Montresor finishes the wall and then breaking the chain or the padlock. The mortar in the wall would still be damp, and he could knock out enough stones to get free of the niche. He is doing everything in silence because he doesn't want Montresor to guess what he is up to..
I laid the second tier, and the third, and the fourth; and then I heard the furious vibrations of the chain.
Fortunato has failed to find any weak place in the chains or padlock. Now he is desperate and starts struggling. It is futile.
A succession of loud and shrill screams, bursting suddenly from the throat of the chained form, seemed to thrust me violently back.
Fortunato is panicked. But he finds out that screaming for help is useless when Montresor starts screaming along with him. They are deep underground. Nobody could possibly hear them.
“Ha! ha! ha!—he! he! he!—a very good joke, indeed—an excellent jest. We will have many a rich laugh about it at the palazzo—he! he! he!—over our wine—he! he! he!”
As a last resort, Fortunato pretends that he believes this is all a practical joke. He is giving Montresor an excuse for changing his mind about killing him. He knows that Montresor might have some misgivings about having been seen with him just before he disappeared. He thinks he can make Montresor believe that he was expected at home that night and people would be out searching for him if he failed to appear. So he tries to plant some fears in Montresor's mind.
“He! he! he!—he! he! he!—yes, the Amontillado. But is it not getting late? Will not they be awaiting us at the palazzo, the Lady Fortunato and the rest? Let us be gone.”
He says "awaiting us" to suggest that many people had observed them together and assumed they were on their way to Fortunato's palazzo. Montresor had previously established that Fortunato was not expected anywhere. He had twice pretended he thought Fortunato had an "engagement," and the second time he had suggested this, Fortunato had said: “I have no engagement;—come.”
So the first indication that Fortunato realizes Montresor is his enemy, not his friend, and that his enemy has him in his power and intends to kill him, is when he utters that "low moaning cry from the depth of the recess." Fortunato never really believes this is a practical joke. He tries desperately to escape and uses psychology as a last resort, but in the end he is left to die. Montresor concludes his narrative with these words:
Against the new masonry I re-erected the old rampart of bones. For the half of a century no mortal has disturbed them. In pace requiescat!