Disable the internal keyboard of a MacBook Pro
From this post on MacRumors forums:


  To disable the Macbook keyboard, type (or copy and paste) the following into terminal:

sudo kextunload /System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext/

  
  To re-enable it, type (or copy and paste) the following into terminal (if copying and pasting, don't forget to copy a linebreak to make the command work):

sudo kextload /System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext

  
  External keyboards will still work.


Tested to work on macOS High Sierra 10.13 and macOS Mojave 10.14.



Alternatively, you can use Karabiner, a 3rd party app for macOS has a feature which lets you automatically disable the internal keyboard of your MacBook when an external one is connected.