def encode_integer_leb128(value):
    """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'\x00'
    n_bits = value.bit_length() + 1
    if n_bits % 7:
        n_bits += 7 - n_bits % 7
    mask = (1 << n_bits) - 1
    value &= mask
    output = bytearray(n_bits // 7)
    for i in range(n_bits // 7):
        output[i] = 128 | value & 127
        value >>= 7
    output[-1] &= 127
    return bytes(output)
