Can you lose fat by weight lifting?
Yes, you can lose fat through weight lifting.
The purpose of weight training should be to get stronger. This should be your focus. Don't get this wrong as your weight lifting workouts might turn into something they shouldn't be.
Definitely weight lifting will burn fat and help you to burn even more fat than other forms of exercise. But, you shouldn't change your workouts to burn more calories or burn the fat away through weight lifting.
For example, I see so many workouts that just do the same weights and resistance over and over again. There's workout videos that people follow over and over again. Same thing is done each time.
No, this is bad and doesn't help you as much as focusing your weight training on strength gains.
For instance, when you lift weights for strength, you will rest a minute to maybe even 5 minutes between sets. For those other workouts that are just burning calories for fat loss, you just go from one exercise to the next with very little rest. This doesn't maximize your strength gains.
You can use cardio workouts for improving your fitness levels and also to burn fat, but focus your weight training on getting stronger. If you aren't getting stronger, you aren't building muscle.
More muscle means you are burning more calories overall. So focus on gaining strength which builds muscle which burns more calories which burns more fat.