I would like to upgrade my iMac 2017 4K Retina 21.5 inches
You have three questions here, so I'll try to answer in order asked.

Is the iMac still under warranty if internally upgraded (RAM &amp; hard drive)?

It depends on where you live because you may or may not be covered by laws that protect you.  In the US, we have the Magnuson-Moss Warranty Act which allows you to open/service your product without fear of invalidating the warranty.  Specific to your situation,
They cannot &quot;tie in&quot; genuine Apple Parts (i.e. hard drives or memory) to keep the warranty in tact:

(c) Prohibition on conditions for written or implied warranty; waiver by Commission; No warrantor of a consumer product may condition his
written or implied warranty of such product on the consumer’s using,
in connection with such product, any article or service (other than
article or service provided without charge under the terms of the
warranty) which is identified by brand, trade, or corporate name;

However, you need to check your local laws governing repairs to see if you're covered.  Generally speaking however, it's very difficult to impossible to tell if you've opened an iMac (there's no tamper seal).  So technically, they wouldn't know.


Is it possible to do it myself or I need a professional technician?

It depends on your technical skill.  You have to remove the LCD which means literally cutting the adhesive that bonds the LCD to the frame of the iMac.  If this is not something you're comfortable doing, take it in for service.

Could you evaluate the cost of internal upgrade compared to external solution with SSD drive (without RAM)?

It's a moot point.  Plugging in an external SSD is easier and will be cheaper if you need to hire a tech to install the drive internally, but the internal drive will always be faster are more reliable.  Bottom line is the external drive doesn't require special skills to install, so you won't have to pay for it.