You cannot directly interface a ultrasonic sensor with with bolt, You will need to interface it first with an arduino.
Then interface the arduino and bolt over UART.
This should be the your code flow.
Arduino continuously monitors the sensor and stores the range in a global variable.
When the arudino receives a serial command from Bolt (Put this in a serialEvent function) the arduino will reply with the range value over the UART to the Bolt.
This can be done in a single command from cloud using the serialWR command of Bolt. On the local network too , if you are using the older version of Bolt.
For interfacing arduino and bolt you can refer the discussion from Range sensor with bolt: