Not only it’s very possible to build muscle mass while following a ketogenic or low carb diet, but it’s worth noting that most of the early bodybuilder were following a “steak and water” diet most of the year, diet that was pretty much what is now called a carnivore diet.
It’s important to note that not all keto diets are the same in terms of efficacy, though: you need a high protein diet, with *at least* 2 grams of proteins per kg of body weight (1 gram per pound approximately), with the best results for most men coming from eating close to 3 grams per kg of body weight.
Diet is not all, of course: instead of pumping light weights with high reps and low rests, you need a specific training program, again pretty much what bodybuilders used to do in the Fifties and Sixties.
How should you train?
1) keep your rests between sets high enough to replenish ATP (3 to 6 minutes)
2) do low reps in the 4-6 range to preserve muscle glycogen and stimulate hyperplasia and mitochondrial hypertrophy
3) choose the frequency that better suits the intensity you are able to achieve, with beginners training every muscle group up to three times a week and advanced athletes training every muscle only once a week, sometimes even taking a week away from the gym to let muscle supercompensate completely.