Many clients that l have worked with have asked me this question, hence this has been their goal.
While somewhat difficult it is not impossible to put on muscle while dropping body-fat. We know that in order to drop body-fat we need to be in a calorie deficit. Meaning that you are burning more calories throughout the day than what you are consuming. Whether and how much muscle one can put during this stage of dieting would depend on several factors. Two of the main factors will be:
THE HISTORY OF THE PERSON'S DIET. We know that every calorie is not the same. Protein, carbs and fats are all different and have different purposes in the body. Proteins are the main muscle building blocks. If a person's diet has been very low in protein and all of a sudden the majority of his calories come from high quality protein then there is a higher chance that he would be putting on muscle even though he is in a calorie deficit. This would be much more noticeable if the person does resistance training at the same time.
THE HISTORY OF THE PERSON'S TRAINING. We know that resistance training stimulates muscle growth. However, the longer and more intensely one has trained the harder it would be for that person to put on muscle especially on a low calorie diet. On the other hand, it is very likely that a beginner would easily put on muscle even if he is on a calorie deficit diet.
There are other smaller factors that can contribute to putting on muscle whilst dieting. These include: The type of training, the intensity of training, timing and type of meals consumed at certain periods of the day, etc.
Whilst putting on muscle while dieting is not an easy task it is not impossible at the same time. I have personally dealt with great number of clients who have achieved that.