I haven’t had need to try this myself, but from my reading of TFM it looks like a negated pattern would do what you want. You can override entries in .gitignore with later negated entries. Thus you could do something like:
*.c
!frob_*.c
!custom.c
To have it ignore all .c files except custom.c and anything starting with “frob_”