Yes. If you freeze raw food, thaw it and cook it and then refreeze it.
The key is make sure you properly thaw it and freeze it right away after cooking it. Bacteria are not killed by freezing food so you have to follow proper food storage methods.
Refreezing food is not dangerous, the danger is that food can spoil before it's refrozen or after it's thawed again before being cooked and eaten.
Freezing food does not kill bacteria, so once thawed bacteria continues to multiple at the same exponential rate it was multiplying at before being frozen.
Refreezing also reduces quality because the already slightly damages cells are being expanded with ice crystals again. This isn't a big deal for meats or baked foods but is huge for rice, pasta, fruits and veggies.