Is there a way to force a password check on a Macbook using Touch ID I like to be able to use Touch ID for quickly unlocking my Macbook, e.g. for when I've walked away from the machine for a few minutes but it's still in a safe place.

But I'd also like to be able to lock it properly, with a password, for when I'm taking it out of the office or otherwise want to enforce more security.

By default you need to enter your password after a system restart, or if you get 5 failed fingerprints in a row, or after no login for 48 hours.

Is there a command-line command, or a programmatic way to replicate this state, so I could script it using one of the various automation tools out there?
You're looking for the command line tool bioutil.  Probably with the -u option.

Usage:
bioutil {-r | -w [-f { 0 | 1 }] [-u { 0 | 1 }] [-a { 0 | 1 }]} | [-c] | [-p] | [-d &lt;uid&gt;] [-s] 

Options:
    -r, --read                      Read current Touch ID settings
    -w, --write                     Write new Touch ID settings
    -s, --system                    Flag to read/write systemwide Touch ID settings or perform systemwide operations
    -f, --function                  Enable (1) or disable (0) Touch ID functionality in general (system settings only)
    -u, --unlock $value             Enable (1) or disable (0) Touch ID for unlock
    -a, --applepay $value           Enable (1) or disable (0) Touch ID for ApplePay (user settings only)
    -c, --count                     Print number of enrolled fingerprints of the current user or of all users (-s, administrator only)
    -p, --purge                     Delete all enrolled fingerprints of the current user or of all users (-s, administrator only)
    -d, --delete $uid               Delete all enrolled fingerprints of the given user (administrator only)