How to safely refreeze cooked beans?
Sure.
I have done this dozens of times.  Beans are durable and super forgiving.  They might get a little mushy but that is fine for black beans.
For other kinds of food the risk is that the might get overcooked the second time and lose character you want.