Can I eat junk food and still lose weight?

Yes, if total calories are low enough. Calrorie balance still governs weight loss. But that does not make a mostly low-nutrient, highly rewarding diet a good strategy. You can lose fat with some "junk food" in the diet; the problem is that a diet built around those foods usually makes satiety, health, training, and adherence worse.

The issue is not "processed" as such. Protein powder, Greek yogurt, canned vegetables, frozen fruit, tofu, pasteurized milk, and cooked rice are all processed in some sense. The more useful question is whether the food is hyperpalatable, calorie-dense, low in fiber or protein, low in micronutrients, and easy to overeat. In a tightly controlled study, a diet labeled "ultra-processed" led people to eat more calories and gain weight compared with an "unprocessed" diet matched for presented calories and macros. The likely practical mechanism was not processing magic; it was that the diet was easier to eat quickly, less filling per calorie, and more rewarding.

So the right approach is inclusion without dependence. Keep your defaults built around protein, produce, fiber, minimally hyperpalatable meals, and generally high food quality. Then fit lower-nutrient foods deliberately when they help your life or adherence. A cookie you planned for is not a problem, but a food that reliably turns into an uncontrolled episode is a context problem that needs better structure.

The practical test is simple: Does this food fit your calorie target, preserve your appetite control, and leave the rest of the diet nutrient-dense enough? If yes, it can fit. If no, reduce frequency, change portioning, keep it out of the house, or reserve it for contexts where it is easier to manage.