Yes, up to a point, but bear in mind that as the tree grows, almost half of it could be hanging over the fence into your neighbour’s garden. Neighbour might not welcome this and has the right to chop off the overhanging growth.
I regret planting a young apple tree so close to the fence. I should have planted in farther away and/or trained it so that the main branches grew parallel to the fence. Hindsight is a marvellous thing!