Sure, “gonna” is fine. Good dialogue is a condensed version of how real people talk. It’s an illusion, a distortiopn of reality, but teh read must believe the illusion. So you take out most of the “er,” “ah,” etc., you don’t let the character drift off topic as often, and you don’t let him talk as much, but he still must sound real.
A reader need to believe the character really would talk exactly like you have him talking, so the quetsion becomes “If this character were real, and you met him, would he use teh word “gonna”?
If the answer is yes, then you need to let him use it.