dd input/output error. No information in error string
For a bootable flash drive, follow the Ubuntu help:


This will be easier since there is the Etcher app you download to avoid the direct use of the dd command.


https://tutorials.ubuntu.com/tutorial/tutorial-create-a-usb-stick-on-macos#0

While I recommend using the Ubuntu ISO image with Etcher, my comments on the use of the dd command follow. You seem to be following the instructions from the link below. You got the wrong device name, /dev/rdisk2s2. You need the disk name not the partition name. You should remove all external drives except your flash drive.  This will make it easier to identify the flash drive and reduce the risk from using the dd command. Try the instructions again from the beginning. 

https://itsfoss.com/create-bootable-ubuntu-usb-drive-mac-os/