def encode_integer_leb128(value: int) -> bytes:
    """Encode an integer with signed LEB128 encoding.

    :param int value: The value to encode.

    :return: ``value`` encoded as a variable-length integer in LEB128 format.
    :rtype: bytes
    """
    if value == 0:
        return b"\0"

    # Calculate the number of bits in the integer and round up to the nearest multiple
    # of 7. We need to add 1 bit because bit_length() only returns the number of bits
    # required to encode the magnitude, but not the sign.

    n_bits = value.bit_length() + 1
    if n_bits % 7:
        n_bits += 7 - (n_bits % 7)

    # Bit operations force a negative integer to its unsigned two's-complement
    # representation, e.g. -127 & 0xff = 0x80, -10 & 0xfff = 0xff6, etc. We use this to
    # sign-extend the number *and* make it unsigned. Once it's unsigned, we can use
    # ULEB128.
    mask = (1 << n_bits) - 1
    value &= mask

    output = bytearray(n_bits // 7)

    for i in range(n_bits // 7):
        output[i] = 0x80 | (value & 0x7F)
        value >>= 7

    # Last byte shouldn't have the high bit set.
    output[-1] &= 0x7F
    return bytes(output)