How to upload sketch to ESP8266 in UNO+WiFi R3 ATmega328P+ESP8266?

I have recently bought UNO+WiFi R3 ATmega328P+ESP8266, 32Mb flash, USB-TTL CH340G, Micro-USB.

I am trying to upload a sketch to it but I am not sure which board to select and what steps to follow?
Do I need to upload firmware first? Should I burn the NodeMcu firmware to it first?

All depends on what you’re trying to do. Want to program the ESP8266 on its own? With Arduino or the Lua NodeMCU firmware? Or do you want to put the latest AT firmware on th ESP8266 and control everything from the ATMega?

You can treat the ESP8266 chip with 4MByte flash on the board as a nodemcuv2 board with a slightly different reset method as shown in the link.

[env:esp8266]
platform = espressif8266
board = nodemcuv2 
framework = arduino
; So that we get "Reset method: ck" as per screenshot 
board_upload.resetmethod = ck

If you want to program the ATMega328P on the board, just treat it like a normal uno.

Note that you have to set up the switches on the board as shown per your link to upload to a specific microcontroller, and put them in other positions to connect them together.