Mindsensors sensors let you change the address by sending the command
0xA0, 0xAA, 0xA5, <new I2C address>
to the sensor. This can be done the sendData method of I2Sensor or any sensor class that inherits from this. The new address can then be specified by calling setAddress on any I2C sensor class. (The address used on setAddress is <new I2C address> divided by 2).
Are you using the Mindsensors or the HiTechnic compass sensor? I am not sure if you can use the same command to change the address with HiTechnic sensors and the Lego ultrasonic sensor.