For the problem described in the question, with the added assumption that a finite set of potential warehouse locations is specified, a MILP model would look as follows. There would be a binary variable for each location (place a warehouse there or not) and a constraint that those variables sum to $M$ (or sum to less than or equal to $M$ if you are not required to use the full quota of warehouses). For each pair of customer and potential location there would be a binary variable (assign that customer to that location) along with constraints that every customer be assigned once and every no assignment can be made to a location without a warehouse. The objective would be the weighted sum of the assignment variables, with the distances being the weights.
Note that this is a rather bare-bones warehouse location problem. More common variants in supply chain management have capacity limits on warehouses, plus constraints that the total demand allocated to each warehouse not exceed its capacity. It is fairly common (though not universal) that client demands can be split across warehouses if desired. The objective function might combine the cost of fulfilling demands (which likely would depend on distances from warehouse to customer) plus possibly a construction/"setup" cost for placing a warehouse at a location, plus possibly a cost component dependent on the capacity of a warehouse (if it is possible to build various size warehouses at a site), plus possibly an operating cost for each warehouse (which again might be dependent on capacity).