code: def set_int(bytearray_, byte_index, _int):
      
      # make sure were dealing with an int
      _int = int(_int)
      _bytes = struct.unpack('2B', struct.pack('>h', _int))
      bytearray_[byte_index:byte_index + 2] = _bytes
      return bytearray_
docs: Set value in bytearray to int