Castagna was born in Għaxaq on 19 November 1765. During the French occupation of Malta in 1798, he was chosen as a representative of the municipality of Żurrieq, Safi, Kirkop and Gudja. When a rebellion against French rule broke out in September 1798, Castagna supported the rebel cause and he was involved in the capture of Saint Thomas Tower from the French. On 18 February 1799, he was elected as a representative of Gudja to the rebel "Consiglio Popolare". He was also appointed as inspector of fortifications by the British Civil Commissioner Alexander Ball.