Yes, you can build muscle on keto and no, you will not necessarily lose muscle mass on low-carb diets. Studies show that the ketogenic diet has a muscle-sparing effect, i.e. it helps you build and preserve muscle tissue rather than lose it  despite the lower-carb intake.
Besides that, compared to low-fat ( and reduced-calorie) diets, you're also getting the benefits of fat-adaption on keto . This helps your body burn fat for energy during workouts rather than protein.
In contrast, on calorie restricted weight-loss diets the body often ends up using proteins from muscle and converting it to glucose for energy . What's worse, your RMR also plummets making further weight loss next to impossible .
With all this in mind, keto is the perfect diet for both weight loss (fat burning) and muscle building (anabolism), which is what most people want when they are trying to improve their body composition, health, and fitness levels.