There are questions about whether the idea of a first cause is coherent or required. If the universe has always existed then it does not need and cannot have a first cause. Also if everything requires a cause, then the first cause also requires a cause. Further, if the existence of everything in the universe requires a cause and needs to be explained by other things, it does not follow that everything - the whole - needs to be explained by a single thing, the first cause. (Fallacy of Composition.) There could be separate chains of causation that between them explain everything but which do not track back to and converge on a single (first cause) source.
If the first cause was (as its name implies) the first or ultimate cause of everything that exists, then since nothing preceded it there is nothing to engender it. It originated ex nihilo, out of nothing. If this is possible, it doesn't answer the question whether it emerged necessarily or contingently. Nor do I see on the data how the question could be answered.
One move is to argue that the first cause brought itself into existence - Spinoza's causa sui or self-caused. It is hard to see how this can be literally true; the first cause would have to precede its own existence in order to bring itself into existence. This doesn't do justice to Spinoza's use of the expression, causa sui, but then that use is tied to contestable 17th-century and earlier assumptions about substance, a concept most of us now have difficulty with.
If we do take causa sui literally and can make sense of it, I can't see how we can tell whether the first cause caused itself necessarily or contingently.