Amazon.com Inc. agreed to add Grubhub to its suite of Prime services in the U.S., in a deal that also gives the e-commerce giant the option to acquire a small stake, the parent of the food-ordering company said.