It's possible, but has the potential to be very very complicated. There are essays and essays about how good camera control is handled in games, and there are a lot of subtle differences between games too, so there's not really a one size fits all type of solution.
For your described scenario, you'll want to identify the center point between the selected units, and then set bounds for the "camera" object based on that center point. The clamp() expression can be used to keep a value (x and y positions in this case) within those bounds.
First the center point. Assuming you want a flexible number of units, you'll want two variables (or an invisible helper sprite) to keep track of x and y values. Add all the selected x or y positions together and divide by the number of units selected. How exactly you go about picking the units will be dependant on how your unit selection is set up.
For the scroll to camera object, every tick set it's x position to clamp(centerpoint.x-range,self.x,centerpoint.x+range) and similar for y, where range is how far you want the camera to be able to move from the center.
You'll probably eventually want some way to have the camera automatically drift or reset back to the center as well. You'll need to describe under what conditions and how you want that to happen.