The question and answer are grammatically correct. The verb 'Was' is used correctly with the singular subject 'weather' in the past tense. The short answer 'Yes, it was' correctly uses the past tense of 'to be'.
Answer: Was the weather sunny last Tuesday? - Yes, it was.