If the computer is still under AppleCare, I'd advise against it. Better to find an external solution.
Built-in drives on those iMacs have specialized firmware which controls the fan speeds. When you replace with a different drive, two things happen: the fans will rev up to full speeds at all times, and the drive will fail the Apple Hardware Test should you ever run that.
The fan issue can be solved with HDD Fan Control:
So the answer is yes, with warnings.