In brief, $out with modes "insertDocuments" and "replaceDocuments" can write to a sharded collection.
$out with mode "replaceCollection" is prohibited when the output collection is sharded.
See the $out design document for details.
Engineering Ticket Description:
For aggregations in a sharded cluster, it would be useful for the $out pipeline operator to support output to a sharded collection, to support use cases where the result set of the aggregation is large.