How can I avoid lens reflection during long exposures using ND filters?

For starters, you can place the filter in the nearest location, to slightly reduce the gap.

If this is still noticeable, I would try to use black electrical tape on the hole.
Do not forget to remove it before storing it for an indefinite period. This is the kind of easy-to-start cassette, but that gets terribly gooey if you forget it for 6 months.

Potentially, it could just light through the filter rather than edges, so you still can not eliminate it completely.
If it passes through the filter itself, you can use each of the 3 slots of the filter holder and see which one gives the least visible result.

… and the idea of ​​xiota of a sun visor could work if the light causing the interference had just come out of the frame. I've never tried putting a hood on a Cokin, but maybe someone does a matte box that can fit into one of the sites?

Ouch – if you have money – Cokin Matte Box, model Z360 with integrated filter holder Z-Pro