Coca-Cola, McDonald’s and Unilever said some consumers were shifting their spending in response to rapidly rising prices, after Walmart rattled the market with a warning about unsold inventory.