Electrum 2FA Wallet - Deriving the Third XPub
After looking into the source code for the Electrum Wallet a bit further I was able to come up with a working implementation in JavaScript.

The problem I described in my question was that the long_user_id is 32 bytes while you only need 4 bytes to derive a child key. It turns out that the third xpub is actually not a child of the hard-coded signing xpub, but rather a root key derived from that signing key (i.e. it has a completely different chain code and its index is 0).

Here's the function I wrote which takes the two wallet xpubs (found under x1/ and x2/ in the wallet / keystore file) and the hard-coded xpub from Trustedcoin and derives the third xpub.

import HDKey from 'hdkey';
import crypto from 'crypto';
import secp256k1 from 'secp256k1';

function getCosignerXPub(xpub_x1, xpub_x2){
    const signing_xpub = "xpub661MyMwAqRbcGnMkaTx2594P9EDuiEqMq25PM2aeG6UmwzaohgA6uDmNsvSUV8ubqwA3Wpste1hg69XHgjUuCD5HLcEp2QPzyV1HMrPppsL";

    const xpubs = [xpub_x1, xpub_x2].sort().join("");
    const long_user_id = new Buffer(sha256(xpubs), 'hex');

    const hdkey = HDKey.fromExtendedKey(signing_xpub);

    const data = Buffer.concat([hdkey.publicKey, long_user_id]);

    const I = crypto.createHmac('sha512', hdkey.chainCode).update(data).digest();

    const IL = I.slice(0, 32);
    const IR = I.slice(32);

    const hd = new HDKey(hdkey.versions);

    hd.publicKey = secp256k1.publicKeyTweakAdd(hdkey.publicKey, IL, true);
    hd.chainCode = IR;

    return hd.publicExtendedKey;
}