Yes, you can use your iPhone or iPad to recover deleted iMessages from iCloud. But for it to work, your device must have had the iCloud backup feature enabled before you mistakenly deleted the wrong message or conversation. However, this will restore not just your iMessages, but make everything else on your iPhone go the way it was when the last backup was performed. So there is a risk of losing newer data.