Bonding with passkey is shown in ble_app_gls in the SDK, so it might be useful to take a look on it.
To modify an example not using passkey to do so, you have to change 3 things:
Set MITM in ble_gap_sec_params_t to 1.
Set IO capabilities in ble_gap_sec_params_t to something with either display or keyboard. Refer to table 2.4 in the Core Specification, Volume 3, Part H, section 184.108.40.206 for your possibilities.
Depending on your choice in 2, either, a) if you have a keyboard: Reply to a BLE_GAP_EVT_AUTH_KEY_REQUEST with a call to sd_ble_gap_auth_key_reply(), supplying the key your user entered. b) if you have a display: Show the key contained in the BLE_GAP_EVT_PASSKEY_DISPLAY on your display, so that the user can enter this key on the Central device.