def encode_value_in_name(value, name, max_name_len=20):
    ' Return `name` as fixed-length string, appending `value` as string.\n\n    Form output from `name` if `value <= 1` else `name` + ``\x00`` +\n    str(value).\n\n    Return output as fixed length string length `max_name_len`, padded with\n    ``\x00``.\n\n    This function also verifies that the modified length of name is less than\n    `max_name_len`.\n\n    Parameters\n    ----------\n    value : int\n        Integer value to encode.\n    name : str\n        Name to which we may append an ascii / latin-1 representation of\n        `value`.\n    max_name_len : int, optional\n        Maximum length of byte string that output can have.\n\n    Returns\n    -------\n    encoded_name : bytes\n        Name maybe followed by ``\x00`` and ascii / latin-1 representation of\n        `value`, padded with ``\x00`` bytes.\n    '
    if len(name) > max_name_len:
        msg = ("Data information named '{0}' is too long (max {1} characters.)"
            .format(name, max_name_len))
        raise ValueError(msg)
    encoded_name = name if value <= 1 else name + '\x00' + str(value)
    if len(encoded_name) > max_name_len:
        msg = (
            "Data information named '{0}' is too long (need to be less than {1} characters when storing more than one value for a given data information."
            .format(name, max_name_len - (len(str(value)) + 1)))
        raise ValueError(msg)
    return encoded_name.ljust(max_name_len, '\x00').encode('latin1')
