To change an engine on an Audi with all the electronics and imobiliser stuff is a nightmare.
You'd be far better off changing the car.
If the car is sentimental and you're adamant to do it then the best option would be to buy another A3 that is ULEZ compliant and changing everything over including engine, gearbox, ECU, full wiring loom, instrument cluster, high pressure fuel pump etc.