import math


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

    :param int value: The value to encode.

    :return: The encoded integer.
    :rtype: bytes
    """
    if value == 0:
        return b"\0"

    if value < 0:
        sign_bit = 0x40
        value = -value
    else:
        sign_bit = 0

    n_bits = value.bit_length()
    n_bytes = 1 + int(math.ceil((n_bits - 6) / 7))

    buf = bytearray(n_bytes)

    for i in range(n_bytes - 1, 0, -1):
        buf[i] = 0x80 | (value & 0x7F)
        value >>= 7

    buf[0] = 0x80 | sign_bit | (value & 0x3F)
    buf[-1] &= 0x7F

    return bytes(buf)