Spanish vlogger Kanghua Ren "violated the moral integrity" of the victim of his 2017 prank, the New York Times reported the Barcelona court as saying.
The court also ruled Ren's YouTube channel, ReSet, must be shut down - and he must not post any videos until 2024.
Ren has also been ordered to pay his victim €20,000 (£17,700) compensation.
The New York Times said Ren was unlikely to spend any time in jail, though, as Spanish courts typically suspend sentences of under two years for first-time offenders found guilty of committing non-violent crimes.
The homeless man was identified by Spanish media as Gheorge L - a Romanian who worked as a shepherd before moving to Barcelona.
Court documents excerpted in Spanish newspapers show Ren made about €2,000 from adverts that ran on the film of the prank.
They said the prank was not an "isolated act" - Ren had carried out other "cruel" tricks on other vulnerable victims.
The filmed prank, which left the homeless man vomiting, brought widespread condemnation for Ren.
He deleted the video from his channel following the criticism, went to see the man again and offered him €20.
Later, he offered to pay the man €300 if he did not start legal action over the stunt.
Ren undertook the prank after being challenged by one of his 1.2 million followers to eat a toothpaste-filled biscuit himself.