Just like piano, you have to know the instrument to comfortably be able to form chords; unlike piano, most notes on the guitar can be played in the same octave at 3, 4, 5 locations on the fretboard. This makes it challenging to develop a mental map of the fretboard, and it may seem like a daunting project at first. Systems like CAGED (which I am frankly not too excited about) are supposed to assist you in developing a such a mental map, and they can be somewhat helpful in this regard. CAGED in particular seems most useful in helping to connect scale patterns to chord tones, but I personally don't think that it has much value in helping one understand how to voice chords on the neck.
You need to get a basic collection of chord shapes under your hands so that you can play them without thinking, and in such a way that you know what note each finger is covering. If you can develop an instant recognition of the notes on the fingerboard, that is helpful (and I would suggest working on this), but what you really need to know is which note is the root, which the third, and so on.
A very useful way to begin is to get comfortable with some basic chord voicing types, learning how to modify those as needed. Here is how I suggest proceeding:
Learn to play triads on the four 3-string groups
One useful strategy for learning the fingerboard is to focus on string groups. Learn how to play the triads (major, minor, augmented, and diminished) on each of the four 3-string groups, in root position and both inversions. While you are doing this, stay aware of where the root is, where the third is, and where the fifth is. Just like piano, to turn one of the shapes above into a minor triad, lower the third; to turn one of the shapes into an augmented triad, raise the fifth. It would probably be a good idea to spend a week focused on each string group. Practice in every key; try playing common progressions (in every key); try mixing in inversions.
Learn to play shell voicings
If you don't already know about shell voicings, learn about them now. Shell voicings contain the root, third, and seventh of a chord (the root and the guide tones); these voicings capture the essential character of seventh chords, and are a really useful tool to have in your kit. These are great for when you are playing from a chart that you have never seen before and you need to simplify the harmony as you begin to find your way. They are also somewhat spare, so they leave some space for other players to fill in.
Pay attention to where the root is, where the third is, and where the seventh is. Lower the third to make a m7 chord; raise the seventh to make a M7 chord; lower the third and raise the seventh to make a mM7 chord; drop the seventh by a whole-step to make a sixth chord. You could try to learn the inversions with these, but I would just focus on learning them in root position to start. Try them in common chord progressions; play them in every key.
Learn to play drop-2 voicings on the three 4-string groups
If you don't already know about drop voicings, learn about them now. To start, I would focus on drop-2 voicings (I have shown some drop-2 voicings above), and maybe add drop-3 voicings after you get good with those. They are very common on both piano and guitar, and provide a systematic way to think about a lot of seventh chord voicings. As with the other voicings, pay attention to where the root is, where the third is, where the fifth is, and where the seventh is. Move these notes around to get 7 chords, m7 chords, m7b5 chords, 7#5 chords, M7#5 chords, etc. Learn all of the inversions, and practice them in common chord progressions in every key. When you start working with drop voicings, you will find that some fingerings are difficult to play at first, and sometimes when you modify a shape to create a new chord you end up with an unplayable fingering, meaning that you may need to find a new fingering for that chord voicing, or you may need to try another voicing altogether.
Use the voicings that you know as a base to create new chord fingerings
If this all seems like a lot of work, it is. There are really only a few types of chord voicings listed above, but there is a lot to do in order to really get those voicings under your hands. Once you do that, you will have a good base to build on, but almost immediately you will be able to apply these voicings to real music. Even if you are shaky on the inversions, having a command of the root position voicings I listed above will give you a lot to use.
When you encounter a chord that you want to play, try to see how it fits with the voicings you know. Shell voicings are particularly useful for this in that they give you the root, third, and seventh, which you can modify to get the right type of seventh chord, and add notes or extensions to color. Need to play a G7#11? Take a G7 shell voicing and add a #11 (or think of it as a G7b5 and add a b5):
Need to play a CMaj9? Take a CMaj7 shell voicing and add a 9:
Note that the fingerings in the above G7#11 and CMaj9 chords take the shell voicings shown earlier, but use different fingers for some of the notes. It is important to be able to play any chord shape using as many different fingering options as you can. ggcg makes good points about this in his answer below. Especially with simple shapes like the triads and shell voicings shown above, practice playing them using different fingers, and practice using different fingerings to move from one shape to the next; when you find a rough patch in a chord change, figure out an efficient fingering and practice it. Eventually your fingers will know where to go and how to get there.
You really do need to know the notes on the fingerboard well, but the way of thinking I have described above is more about knowing where the chord tones and chord extensions are in relation to chord shapes that you already know. Once you gain some facility with this, you will be an unstoppable chording machine.