The assumption that the physical world must be lifeless and non-sentient arises is somewhat modern and became prominent along with the rise of a European secular worldview. Peoples throughout history have held (and continue to hold) a variety of views of whether or not there is some inherent intelligence or sentience in nature.
Anyway, a literal reading of the verse suggests that the mountains do indeed have some level of awareness or comprehension, such that they were able to understand what it would mean to be offered the "trust" (amanah), and reply.
Other interpretations of this verse include:
* The verse is metaphorical. That is, it means to say, if the mountains were able to speak and understand, this is what they would say - to emphasize the enormity of the amanah.
* The verse is referring to the inhabitants of the earth and mountains, such as people, earth, jinn, and angels. This view exists but is somewhat odd since humans took on the amanah.
Personally I favour the literal understanding. It is in line with the Qur'anic verse that says that everything glorifies Allah but we do not understand it. So just we cannot understand the mountains does not mean they have no ability to communicate with Allah. However others may prefer other views.
Even if one does not accept this literal meaning, it should be noted that on the Day of Resurrection, it is said that the earth will be able to speak and bear witness to what happened upon it, so the natural world will have awareness and the ability to speak then.