def write_variable_length(value):
    """
    Write a variable length variable.

    Parameters
    ----------
    value : bytearray
        Value to be encoded as a variable of variable length.

    Returns
    -------
    bytearray
        Variable with variable length.

    """
    result = bytearray()
    result.insert(0, value & 0x7F)
    value >>= 7
    if value:
        result.insert(0, (value & 0x7F) | 0x80)
        value >>= 7
        if value:
            result.insert(0, (value & 0x7F) | 0x80)
            value >>= 7
            if value:
                result.insert(0, (value & 0x7F) | 0x80)
    return result