You can readily grow an olive tree in a pot, and you can keep its growth restricted over time by pruning, but if you want lots of fruit under those conditions, it's not quite so easy.
First, olives grown for fruit need a two month period of cold weather (temperatures below 10 deg C) in order to initiate fruiting. Prolonged colder temperatures will inhibit fruiting though - 7.5 deg C or lower for a period of time.
Second, the olives are borne on the tips of the previous year's growth, which obviously means you'd need to be careful about how much pruning you do. There are some smaller cultivars which are better suited to restricted spaces, but many of these are non fruiting types.
Third, better fruiting is achieved by growing more than one olive tree; most self fertile ones, though, will produce fruit without another tree nearby, but there are varieties which need another tree for fertilisation of the flowers. Bear in mind that olives are slow growing plants, and fruiting doesn't usually occur before the plant is around five years old anyway. That said, you need also to think about the variety of olive - some are only used for pressing, others for both curing and pressing, and others just cured for eating. The link here http://www.gardeningblog.net/how-to-grow/olives/ gives general information.
The link below gives some useful information on growing olives on a balcony, in pots, and mentions a couple of fruiting varieties which are smaller and therefore better for pot culture
http://lifeonthebalcony.com/how-to-grow-an-olive-tree-in-a-container/
You might also like to know that ripe, black olives can be picked and eaten straight away, but taste nothing like the ones you buy - those will have been picked either when they're green and unripe, or black and ripe, and then cured to produce a more palatable product.