Do you have to be sad to write a sad song? Do you have to be in love to write a love song?
No.
Writing is a type of human labor. Writers bring their toolboxes of historically and personally delimited technical practices to bear on raw materials that are also historically and personally selected, transforming those raw materials into something different.
What matters here is the technique, not the emotional state or subjective perspective or personal opinions of the writer.
Try it and see.