Can I use the esp32 in Arduino Due by connecting it to UART port?
You only have to check that the ESP32 won't output more than 3.3V to the DUE.
BTW, Arduino DUE has 5 hardware Serial (Serial, Serial1, Serial2, Serial3 and Serial4 with the addition of 3 lines of code). Serial should be dedicated to Serial Monitor onto the PC, hence you have up to 4 hardware serials to communicate with an ESP32.
A Due can be directly connected to a ESP32, both are 3.3V devices.
You must have a very good reason to connect two processors together.
Can't the ESP32 do everything?