def encode(content: int) -> bytearray:
    """Encode an integer into a SDNV

    :param content: Integer to encode
    :return: Bytearray containing the encoded value
    """
    if content < 0 or type(content) != int:
        raise ValueError("Invalid content")

    flag = 0
    ret_array = bytearray()
    while True:
        new_bits = content & 0x7F
        content >>= 7
        ret_array.append(new_bits + flag)
        if flag == 0:
            flag = 0x80
        if content == 0:
            break

    ret_array.reverse()
    return ret_array