How can I attach a custom built antenna to the NodeMCU (ESP-12E)
You could try but that  what involves cutting the old  pub antenna trace and soldering onto the ground and the existing trace. It may not work well.

A better choice is to get a esp module with an external antenna connector like a u.fl connector. A wemos d1 mini pro or a clone is compatible with the nodemcu and includes more features for cheap.