Optimal Focusing of scalar fields subject to arbitrary upper bounds