The global shortage of chips could hurt production of iPads and Macs, costing Apple $3 billion to $4 billion in revenue, in what is the latest example of a company being hit by supply constraints.