Optimal focusing of scalar field subject to arbitrary upper bounds