Yes, it's legal to do. The circumstances vary, but to answer only the question of legality operating with a blacked out cockpit, you bet. Yes, without question The military has done it for years (in former training times, blacked out cockpits and socks were standard), quite safely. The first demonstration of an approach and instrument flight, by Billy Mitchell, was done exactly in this manner, without the benifit of modern instrumentation, technology, navaids, or aircraft. And he did it to a complete landing, repeatedly.
The matter is dealt with in 14 CFR 91.109(b). The safety pilot present during simulated instrument flight must be able to meet the field of vision requirements established by 91.109(b)(2). This means being able to have adequate vision forward and to each side of the aricraft. Alternately, a competent observer who has this visibility may be used.
The exact specifics of the answer to your question will vary with the aircraft and the application. In many light aircraft, it may be difficult to achieve the field of vision requirements and still adequately black out the cockpit, and in many others it is possible using a combination of a safety pilot and an observer. It's much easier in tandem aircraft such as a T-34, or T-6, but is also quite possible in many standard training aircraft with side by side seating, if properly done.
Bobby, you're probably thinking of the Francis Hood. It's one of the oldest standard view limiting devices still in use today. Personally, the lightest and most comfortable commercial device I've found is the Jeppshades. Otherwise, it's hard to beat the comfort of a ball cap with cardboard stapled around the outside for ease convenience, and wearability with a headset. A helmet with a sandblasted visor works well, too.