How to attach closet flange to sub floor
I would not leave a gap, and use screws long enough to reach through the plywood through the backer board. Make sure the flange is well supported or you'll have problems with it down the road if not immediately.

Maybe an even better solution would be to have plywood of the right thickness span the gap between the subfloor and the flange, and still use longer screws that will reach the subfloor. Cement backer board tends to be weak at its edges and may not provide the support the flange needs. Plywood on the other hand is very strong at its edges and should hold up marvelously. This small piece of plywood can be kept inside the area that the toilet bowl covers so you won't have to put tiles over it or anything. You might want some plastic shims on hand for the job too, in case the plywood and flange don't meet nicely. Good luck.