The hydrogen sensing characteristics of a single nanotrench fabricated by focused ion beam milling (FIB) in an evaporated palladium microwire are presented. In situ atomic force microscopy (AFM) measurements proved that, in the presence of H2, the trench closes and electrically connects the initially separated parts of the wire due to the increase in volume of the material. Therewith, an electrical current can be switched through the wire. With experiments under various H2 concentrations and a mathematical model, we describe the closing mechanism of the trench with respect to various parameters, including the substrate material, film thickness, trench size and wire dimensions. Results have been compared with those from equivalent continuous wires. Thin SiO2 and polyimide (PI) layers on silicon were used to study the effect of substrate elasticity. Sufficient lateral expansion of Pd to close trenches of up to 70 nm in width has only been observed on PI, which we attribute to its advantageous elastic properties. The scale of the response times allowed the observation of two superposing effects: the chemical conversion of Pd to PdHx and the mechanical closing of the trench.