You can certainly do this without much trouble. You just have to avoid ingredients with wet sugars and fiber. In the end Carbs are 4 calories per gram, protein is 4 calories per gram, and fat is 9 calories per gram. You cannot do any better than that. From: myfitnesspal
The 2010 Dietary Guidelines for Americans recommends eating within the following ranges:
- Carbohydrates: 45-65% of calories
- Fat: 20-35% of calories
- Protein: 10-35% of calories
Let’s say you want to up fat and protein content to increase calories and try to maintain muscle mass. How about 45% carbs, 35% fat, and 20% protein? If you remove all fiber and water your 20 gram bar would have 115 calories. Perhaps with some trace amounts of water fiber 100 cal/20 gram would be a good target. To get any higher calorie content you would have to increase fat content more and this is already at the max recommended by that link. Is that what you are looking for?